convert enums to enum classes, part 3
C++11 cleanup (clean up easy enums) This is for runtime/base/... and ended up touching a lot of files because it turns out we have a lot of reasonably behaved enums.
Esse commit está contido em:
@@ -5350,7 +5350,7 @@ void EmitterVisitor::emitPostponedMeths() {
|
||||
std::string orig = vNode->getComment();
|
||||
if (orig.empty()) {
|
||||
// Simple case: it's a scalar value so we just serialize it
|
||||
VariableSerializer vs(VariableSerializer::PHPOutput);
|
||||
VariableSerializer vs(VariableSerializer::Type::PHPOutput);
|
||||
String result = vs.serialize(tvAsCVarRef(&dv), true);
|
||||
phpCode = StringData::GetStaticString(result.get());
|
||||
} else {
|
||||
|
||||
@@ -595,7 +595,7 @@ void SymbolTable::countTypes(std::map<std::string, int> &counts) {
|
||||
}
|
||||
|
||||
string SymbolTable::getEscapedText(Variant v, int &len) {
|
||||
VariableSerializer vs(VariableSerializer::Serialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::Serialize);
|
||||
String str = vs.serialize(v, true);
|
||||
len = str.length();
|
||||
string output = Util::escapeStringForCPP(str.data(), len);
|
||||
|
||||
@@ -552,7 +552,7 @@ void ArrayData::dump() {
|
||||
}
|
||||
|
||||
void ArrayData::dump(std::string &out) {
|
||||
VariableSerializer vs(VariableSerializer::VarDump);
|
||||
VariableSerializer vs(VariableSerializer::Type::VarDump);
|
||||
String ret(vs.serialize(Array(this), true));
|
||||
out += "ArrayData(";
|
||||
out += boost::lexical_cast<string>(_count);
|
||||
@@ -563,7 +563,7 @@ void ArrayData::dump(std::string &out) {
|
||||
void ArrayData::dump(std::ostream &out) {
|
||||
unsigned int i = 0;
|
||||
for (ArrayIter iter(this); iter; ++iter, i++) {
|
||||
VariableSerializer vs(VariableSerializer::Serialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::Serialize);
|
||||
Variant key(iter.first());
|
||||
out << i << " #### " << key.toString()->toCPPString() << " #### ";
|
||||
Variant val(iter.second());
|
||||
|
||||
@@ -248,7 +248,7 @@ vm_decode_function(CVarRef function,
|
||||
return f;
|
||||
}
|
||||
assert(cls);
|
||||
CallType lookupType = this_ ? ObjMethod : ClsMethod;
|
||||
CallType lookupType = this_ ? CallType::ObjMethod : CallType::ClsMethod;
|
||||
const HPHP::Func* f =
|
||||
g_vmContext->lookupMethodCtx(cc, name.get(), ctx, lookupType);
|
||||
if (f && (f->attrs() & AttrStatic)) {
|
||||
@@ -271,7 +271,7 @@ vm_decode_function(CVarRef function,
|
||||
f = cls->lookupMethod(s___call.get());
|
||||
assert(!f || !(f->attrs() & AttrStatic));
|
||||
}
|
||||
if (!f && lookupType == ClsMethod) {
|
||||
if (!f && lookupType == CallType::ClsMethod) {
|
||||
f = cls->lookupMethod(s___callStatic.get());
|
||||
assert(!f || (f->attrs() & AttrStatic));
|
||||
this_ = nullptr;
|
||||
@@ -746,7 +746,7 @@ String f_serialize(CVarRef value) {
|
||||
}
|
||||
case KindOfObject:
|
||||
case KindOfDouble: {
|
||||
VariableSerializer vs(VariableSerializer::Serialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::Serialize);
|
||||
return vs.serialize(value, true);
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -413,7 +413,7 @@ Variant unserialize_ex(const char* str, int len,
|
||||
inline Variant unserialize_from_buffer(const char* str, int len,
|
||||
CArrRef class_whitelist = null_array) {
|
||||
return unserialize_ex(str, len,
|
||||
VariableUnserializer::Serialize,
|
||||
VariableUnserializer::Type::Serialize,
|
||||
class_whitelist);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ Variant ClassInfo::ConstantInfo::getValue() const {
|
||||
if (!svalue.empty()) {
|
||||
try {
|
||||
VariableUnserializer vu(svalue.data(), svalue.size(),
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
return vu.unserialize();
|
||||
} catch (Exception &e) {
|
||||
assert(false);
|
||||
@@ -224,7 +224,7 @@ Variant ClassInfo::ConstantInfo::getValue() const {
|
||||
}
|
||||
|
||||
void ClassInfo::ConstantInfo::setValue(CVarRef value) {
|
||||
VariableSerializer vs(VariableSerializer::Serialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::Serialize);
|
||||
String s = vs.serialize(value, true);
|
||||
svalue = string(s.data(), s.size());
|
||||
deferred = false;
|
||||
@@ -529,7 +529,7 @@ void ClassInfo::ReadUserAttributes(const char **&p,
|
||||
int64_t valueLen = (int64_t)len;
|
||||
VariableUnserializer vu(valueText,
|
||||
valueLen,
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
userAttr->setStaticValue(vu.unserialize());
|
||||
|
||||
userAttrVec.push_back(userAttr);
|
||||
@@ -594,7 +594,7 @@ ClassInfo::MethodInfo::MethodInfo(const char **&p) {
|
||||
staticVariable->valueText = *p++;
|
||||
VariableUnserializer vu(staticVariable->valueText,
|
||||
staticVariable->valueLen,
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
try {
|
||||
staticVariable->setStaticValue(vu.unserialize());
|
||||
} catch (Exception &e) {
|
||||
@@ -675,7 +675,7 @@ ClassInfoUnique::ClassInfoUnique(const char **&p) {
|
||||
constant->valueLen = (int64_t)len_or_cw;
|
||||
VariableUnserializer vu(constant->valueText,
|
||||
constant->valueLen,
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
try {
|
||||
constant->setStaticValue(vu.unserialize());
|
||||
} catch (Exception &e) {
|
||||
@@ -711,7 +711,7 @@ ClassInfoUnique::ClassInfoUnique(const char **&p) {
|
||||
int64_t valueLen = (int64_t)len;
|
||||
VariableUnserializer vu(valueText,
|
||||
valueLen,
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
userAttr->setStaticValue(vu.unserialize());
|
||||
|
||||
m_userAttrVec.push_back(userAttr);
|
||||
|
||||
@@ -62,7 +62,7 @@ BaseExecutionContext::BaseExecutionContext() :
|
||||
m_cwd(Process::CurrentWorkingDirectory),
|
||||
m_out(nullptr), m_implicitFlush(false), m_protectedLevel(0),
|
||||
m_stdout(nullptr), m_stdoutData(nullptr),
|
||||
m_errorState(ExecutionContext::NoError),
|
||||
m_errorState(ExecutionContext::ErrorState::NoError),
|
||||
m_errorReportingLevel(RuntimeOption::RuntimeErrorReportingLevel),
|
||||
m_lastErrorNum(0), m_logErrors(false), m_throwAllErrors(false),
|
||||
m_vhost(nullptr) {
|
||||
@@ -406,7 +406,7 @@ void BaseExecutionContext::flush() {
|
||||
} else if (RuntimeOption::EnableEarlyFlush && m_protectedLevel &&
|
||||
(m_transport == nullptr ||
|
||||
(m_transport->getHTTPVersion() == "1.1" &&
|
||||
m_transport->getMethod() != Transport::HEAD))) {
|
||||
m_transport->getMethod() != Transport::Method::HEAD))) {
|
||||
StringBuffer &oss = m_buffers.front()->oss;
|
||||
if (!oss.empty()) {
|
||||
if (m_transport) {
|
||||
@@ -520,7 +520,7 @@ void BaseExecutionContext::onShutdownPreSend() {
|
||||
}
|
||||
|
||||
void BaseExecutionContext::onShutdownPostSend() {
|
||||
ServerStats::SetThreadMode(ServerStats::PostProcessing);
|
||||
ServerStats::SetThreadMode(ServerStats::ThreadMode::PostProcessing);
|
||||
try {
|
||||
try {
|
||||
ServerStatsHelper ssh("psp", ServerStatsHelper::TRACK_HWINST);
|
||||
@@ -544,7 +544,7 @@ void BaseExecutionContext::onShutdownPostSend() {
|
||||
} catch (...) {
|
||||
Logger::Error("unknown exception was thrown from psp");
|
||||
}
|
||||
ServerStats::SetThreadMode(ServerStats::Idling);
|
||||
ServerStats::SetThreadMode(ServerStats::ThreadMode::Idling);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -554,7 +554,8 @@ bool BaseExecutionContext::errorNeedsHandling(int errnum,
|
||||
bool callUserHandler,
|
||||
ErrorThrowMode mode) {
|
||||
if (m_throwAllErrors) throw errnum;
|
||||
if (mode != NeverThrow || (getErrorReportingLevel() & errnum) != 0 ||
|
||||
if (mode != ErrorThrowMode::Never ||
|
||||
(getErrorReportingLevel() & errnum) != 0 ||
|
||||
RuntimeOption::NoSilencer) {
|
||||
return true;
|
||||
}
|
||||
@@ -569,7 +570,8 @@ bool BaseExecutionContext::errorNeedsHandling(int errnum,
|
||||
|
||||
class ErrorStateHelper {
|
||||
public:
|
||||
ErrorStateHelper(BaseExecutionContext *context, int state) {
|
||||
ErrorStateHelper(BaseExecutionContext *context,
|
||||
ExecutionContext::ErrorState state) {
|
||||
m_context = context;
|
||||
m_originalState = m_context->getErrorState();
|
||||
m_context->setErrorState(state);
|
||||
@@ -579,7 +581,7 @@ public:
|
||||
}
|
||||
private:
|
||||
BaseExecutionContext *m_context;
|
||||
int m_originalState;
|
||||
ExecutionContext::ErrorState m_originalState;
|
||||
};
|
||||
|
||||
static StaticString s_file("file");
|
||||
@@ -593,20 +595,20 @@ void BaseExecutionContext::handleError(const std::string &msg,
|
||||
bool skipFrame /* = false */) {
|
||||
SYNC_VM_REGS_SCOPED();
|
||||
|
||||
int newErrorState = ErrorRaised;
|
||||
ErrorState newErrorState = ErrorState::ErrorRaised;
|
||||
switch (getErrorState()) {
|
||||
case ErrorRaised:
|
||||
case ErrorRaisedByUserHandler:
|
||||
case ErrorState::ErrorRaised:
|
||||
case ErrorState::ErrorRaisedByUserHandler:
|
||||
return;
|
||||
case ExecutingUserHandler:
|
||||
newErrorState = ErrorRaisedByUserHandler;
|
||||
case ErrorState::ExecutingUserHandler:
|
||||
newErrorState = ErrorState::ErrorRaisedByUserHandler;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ErrorStateHelper esh(this, newErrorState);
|
||||
ExtendedException ee = skipFrame ?
|
||||
ExtendedException(ExtendedException::skipFrame, msg) :
|
||||
ExtendedException(ExtendedException::SkipFrame::skipFrame, msg) :
|
||||
ExtendedException(msg);
|
||||
Array bt = ee.getBackTrace();
|
||||
|
||||
@@ -615,7 +617,8 @@ void BaseExecutionContext::handleError(const std::string &msg,
|
||||
if (callUserHandler) {
|
||||
handled = callUserErrorHandler(ee, errnum, false);
|
||||
}
|
||||
if (mode == AlwaysThrow || (mode == ThrowIfUnhandled && !handled)) {
|
||||
if (mode == ErrorThrowMode::Always ||
|
||||
(mode == ErrorThrowMode::IfUnhandled && !handled)) {
|
||||
DEBUGGER_ATTACHED_ONLY(phpDebuggerErrorHook(msg));
|
||||
throw FatalErrorException(msg, bt);
|
||||
}
|
||||
@@ -640,8 +643,8 @@ void BaseExecutionContext::handleError(const std::string &msg,
|
||||
bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
|
||||
bool swallowExceptions) {
|
||||
switch (getErrorState()) {
|
||||
case ExecutingUserHandler:
|
||||
case ErrorRaisedByUserHandler:
|
||||
case ErrorState::ExecutingUserHandler:
|
||||
case ErrorState::ErrorRaisedByUserHandler:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
@@ -664,7 +667,7 @@ bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum,
|
||||
}
|
||||
}
|
||||
try {
|
||||
ErrorStateHelper esh(this, ExecutingUserHandler);
|
||||
ErrorStateHelper esh(this, ErrorState::ExecutingUserHandler);
|
||||
if (!same(vm_call_user_func
|
||||
(m_userErrorHandlers.back().first,
|
||||
CREATE_VECTOR6(errnum, String(e.getMessage()), errfile,
|
||||
@@ -706,7 +709,7 @@ bool BaseExecutionContext::onFatalError(const Exception &e) {
|
||||
}
|
||||
bool handled = false;
|
||||
if (RuntimeOption::CallUserHandlerOnFatals) {
|
||||
int errnum = ErrorConstants::FATAL_ERROR;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::FATAL_ERROR);
|
||||
handled = callUserErrorHandler(e, errnum, true);
|
||||
}
|
||||
if (!handled && !RuntimeOption::AlwaysLogUnhandledExceptions) {
|
||||
|
||||
@@ -131,12 +131,12 @@ class ClassInfoVM : public ClassInfo,
|
||||
};
|
||||
|
||||
namespace MethodLookup {
|
||||
enum CallType {
|
||||
enum class CallType {
|
||||
ClsMethod,
|
||||
ObjMethod,
|
||||
CtorMethod,
|
||||
};
|
||||
enum LookupResult {
|
||||
enum class LookupResult {
|
||||
MethodFoundWithThis,
|
||||
MethodFoundNoThis,
|
||||
MagicCallFound,
|
||||
@@ -193,13 +193,13 @@ public:
|
||||
ShutdownTypeCount
|
||||
};
|
||||
|
||||
enum ErrorThrowMode {
|
||||
NeverThrow,
|
||||
ThrowIfUnhandled,
|
||||
AlwaysThrow,
|
||||
enum class ErrorThrowMode {
|
||||
Never,
|
||||
IfUnhandled,
|
||||
Always,
|
||||
};
|
||||
|
||||
enum ErrorState {
|
||||
enum class ErrorState {
|
||||
NoError,
|
||||
ErrorRaised,
|
||||
ExecutingUserHandler,
|
||||
@@ -298,8 +298,8 @@ public:
|
||||
void recordLastError(const Exception &e, int errnum = 0);
|
||||
bool onFatalError(const Exception &e); // returns handled
|
||||
bool onUnhandledException(Object e);
|
||||
int getErrorState() const { return m_errorState;}
|
||||
void setErrorState(int state) { m_errorState = state;}
|
||||
ErrorState getErrorState() const { return m_errorState;}
|
||||
void setErrorState(ErrorState state) { m_errorState = state;}
|
||||
String getLastError() const { return m_lastError;}
|
||||
int getLastErrorNumber() const { return m_lastErrorNum;}
|
||||
int getErrorReportingLevel() const { return m_errorReportingLevel;}
|
||||
@@ -374,7 +374,7 @@ private:
|
||||
// error handling
|
||||
std::vector<std::pair<Variant,int> > m_userErrorHandlers;
|
||||
std::vector<Variant> m_userExceptionHandlers;
|
||||
int m_errorState;
|
||||
ErrorState m_errorState;
|
||||
int m_errorReportingLevel;
|
||||
String m_lastError;
|
||||
int m_lastErrorNum;
|
||||
@@ -446,7 +446,7 @@ private:
|
||||
SVarVector m_freedSvars;
|
||||
void treadmillSharedVars();
|
||||
|
||||
enum VectorLeaveCode {
|
||||
enum class VectorLeaveCode {
|
||||
ConsumeAll,
|
||||
LeaveLast
|
||||
};
|
||||
|
||||
@@ -207,10 +207,18 @@ bool SSLSocket::onConnect() {
|
||||
bool SSLSocket::onAccept() {
|
||||
if (m_fd >= 0 && m_enable_on_connect) {
|
||||
switch (m_method) {
|
||||
case ClientSSLv23: m_method = ServerSSLv23; break;
|
||||
case ClientSSLv2: m_method = ServerSSLv2; break;
|
||||
case ClientSSLv3: m_method = ServerSSLv3; break;
|
||||
case ClientTLS: m_method = ServerTLS; break;
|
||||
case CryptoMethod::ClientSSLv23:
|
||||
m_method = CryptoMethod::ServerSSLv23;
|
||||
break;
|
||||
case CryptoMethod::ClientSSLv2:
|
||||
m_method = CryptoMethod::ServerSSLv2;
|
||||
break;
|
||||
case CryptoMethod::ClientSSLv3:
|
||||
m_method = CryptoMethod::ServerSSLv3;
|
||||
break;
|
||||
case CryptoMethod::ClientTLS:
|
||||
m_method = CryptoMethod::ServerTLS;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
@@ -303,16 +311,16 @@ SSLSocket *SSLSocket::Create(const char *&name, int port, double timeout) {
|
||||
CryptoMethod method;
|
||||
if (strncmp(name, "ssl://", 6) == 0) {
|
||||
name += 6;
|
||||
method = ClientSSLv23;
|
||||
method = CryptoMethod::ClientSSLv23;
|
||||
} else if (strncmp(name, "sslv2://", 8) == 0) {
|
||||
name += 8;
|
||||
method = ClientSSLv2;
|
||||
method = CryptoMethod::ClientSSLv2;
|
||||
} else if (strncmp(name, "sslv3://", 8) == 0) {
|
||||
name += 8;
|
||||
method = ClientSSLv3;
|
||||
method = CryptoMethod::ClientSSLv3;
|
||||
} else if (strncmp(name, "tls://", 6) == 0) {
|
||||
name += 6;
|
||||
method = ClientTLS;
|
||||
method = CryptoMethod::ClientTLS;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -395,25 +403,49 @@ bool SSLSocket::setupCrypto(SSLSocket *session /* = NULL */) {
|
||||
const SSL_METHOD *smethod;
|
||||
#endif
|
||||
switch (m_method) {
|
||||
case ClientSSLv23: m_client = true; smethod = SSLv23_client_method(); break;
|
||||
case ClientSSLv3: m_client = true; smethod = SSLv3_client_method(); break;
|
||||
case ClientTLS: m_client = true; smethod = TLSv1_client_method(); break;
|
||||
case ServerSSLv23: m_client = false; smethod = SSLv23_server_method(); break;
|
||||
case ServerSSLv3: m_client = false; smethod = SSLv3_server_method(); break;
|
||||
case CryptoMethod::ClientSSLv23:
|
||||
m_client = true;
|
||||
smethod = SSLv23_client_method();
|
||||
break;
|
||||
case CryptoMethod::ClientSSLv3:
|
||||
m_client = true;
|
||||
smethod = SSLv3_client_method();
|
||||
break;
|
||||
case CryptoMethod::ClientTLS:
|
||||
m_client = true;
|
||||
smethod = TLSv1_client_method();
|
||||
break;
|
||||
case CryptoMethod::ServerSSLv23:
|
||||
m_client = false;
|
||||
smethod = SSLv23_server_method();
|
||||
break;
|
||||
case CryptoMethod::ServerSSLv3:
|
||||
m_client = false;
|
||||
smethod = SSLv3_server_method();
|
||||
break;
|
||||
|
||||
/* SSLv2 protocol might be disabled in the OpenSSL library */
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
case ClientSSLv2: m_client = true; smethod = SSLv2_client_method(); break;
|
||||
case ServerSSLv2: m_client = false; smethod = SSLv2_server_method(); break;
|
||||
case CryptoMethod::ClientSSLv2:
|
||||
m_client = true;
|
||||
smethod = SSLv2_client_method();
|
||||
break;
|
||||
case CryptoMethod::ServerSSLv2:
|
||||
m_client = false;
|
||||
smethod = SSLv2_server_method();
|
||||
break;
|
||||
#else
|
||||
case ClientSSLv2:
|
||||
case ServerSSLv2:
|
||||
case CryptoMethod::ClientSSLv2:
|
||||
case CryptoMethod::ServerSSLv2:
|
||||
raise_warning("OpenSSL library does not support SSL2 protocol");
|
||||
return false;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case ServerTLS: m_client = false; smethod = TLSv1_server_method(); break;
|
||||
case CryptoMethod::ServerTLS:
|
||||
m_client = false;
|
||||
smethod = TLSv1_server_method();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace HPHP {
|
||||
*/
|
||||
class SSLSocket : public Socket {
|
||||
public:
|
||||
enum CryptoMethod {
|
||||
enum class CryptoMethod {
|
||||
ClientSSLv2,
|
||||
ClientSSLv3,
|
||||
ClientSSLv23,
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
class Certificate : public SweepableResourceData {
|
||||
public:
|
||||
X509 *m_cert;
|
||||
Certificate(X509 *cert) : m_cert(cert) { assert(m_cert);}
|
||||
explicit Certificate(X509 *cert) : m_cert(cert) { assert(m_cert);}
|
||||
~Certificate() { if (m_cert) X509_free(m_cert);}
|
||||
|
||||
static StaticString s_class_name;
|
||||
|
||||
@@ -43,7 +43,7 @@ UserFile::UserFile(Class *cls, int options /*= 0 */,
|
||||
m_cls(cls), m_options(options) {
|
||||
Transl::VMRegAnchor _;
|
||||
const Func *ctor;
|
||||
if (MethodLookup::MethodFoundWithThis !=
|
||||
if (MethodLookup::LookupResult::MethodFoundWithThis !=
|
||||
g_vmContext->lookupCtorMethod(ctor, cls)) {
|
||||
throw InvalidArgumentException(0, "Unable to call %s's constructor",
|
||||
cls->name()->data());
|
||||
@@ -107,7 +107,7 @@ Variant UserFile::invoke(const Func *func, CStrRef name,
|
||||
}
|
||||
|
||||
switch(g_vmContext->lookupObjMethod(func, m_cls, name.get())) {
|
||||
case MethodLookup::MethodFoundWithThis:
|
||||
case MethodLookup::LookupResult::MethodFoundWithThis:
|
||||
{
|
||||
Variant ret;
|
||||
g_vmContext->invokeFunc(ret.asTypedValue(), func, args, m_obj.get());
|
||||
@@ -115,7 +115,7 @@ Variant UserFile::invoke(const Func *func, CStrRef name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
case MethodLookup::MagicCallFound:
|
||||
case MethodLookup::LookupResult::MagicCallFound:
|
||||
{
|
||||
Variant ret;
|
||||
g_vmContext->invokeFunc(ret.asTypedValue(), func,
|
||||
@@ -124,17 +124,17 @@ Variant UserFile::invoke(const Func *func, CStrRef name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
case MethodLookup::MethodNotFound:
|
||||
case MethodLookup::LookupResult::MethodNotFound:
|
||||
// There's a method somewhere in the heirarchy, but none
|
||||
// which are accessible.
|
||||
/* fallthrough */
|
||||
case MethodLookup::MagicCallStaticFound:
|
||||
case MethodLookup::LookupResult::MagicCallStaticFound:
|
||||
// We're not calling staticly, so this result is unhelpful
|
||||
// Also, it's never produced by lookupObjMethod, so it'll
|
||||
// never happen, but we must handle all enums
|
||||
return uninit_null();
|
||||
|
||||
case MethodLookup::MethodFoundNoThis:
|
||||
case MethodLookup::LookupResult::MethodFoundNoThis:
|
||||
// Should never happen (Attr::Static check in ctor)
|
||||
assert(false);
|
||||
raise_error("%s::%s() must not be declared static",
|
||||
|
||||
@@ -570,8 +570,8 @@ static StaticString s_PHP_Incomplete_Class_Name("__PHP_Incomplete_Class_Name");
|
||||
void ObjectData::serializeImpl(VariableSerializer *serializer) const {
|
||||
bool handleSleep = false;
|
||||
Variant ret;
|
||||
if (LIKELY(serializer->getType() == VariableSerializer::Serialize ||
|
||||
serializer->getType() == VariableSerializer::APCSerialize)) {
|
||||
if (LIKELY(serializer->getType() == VariableSerializer::Type::Serialize ||
|
||||
serializer->getType() == VariableSerializer::Type::APCSerialize)) {
|
||||
if (instanceof(SystemLib::s_SerializableClass)) {
|
||||
assert(!isCollection());
|
||||
Variant ret =
|
||||
@@ -588,7 +588,7 @@ void ObjectData::serializeImpl(VariableSerializer *serializer) const {
|
||||
}
|
||||
handleSleep = const_cast<ObjectData*>(this)->php_sleep(ret);
|
||||
} else if (UNLIKELY(serializer->getType() ==
|
||||
VariableSerializer::DebuggerSerialize)) {
|
||||
VariableSerializer::Type::DebuggerSerialize)) {
|
||||
if (instanceof(SystemLib::s_SerializableClass)) {
|
||||
assert(!isCollection());
|
||||
try {
|
||||
@@ -649,21 +649,21 @@ void ObjectData::serializeImpl(VariableSerializer *serializer) const {
|
||||
wanted.serialize(serializer, true);
|
||||
} else {
|
||||
if (instanceof(c_Closure::s_cls)) {
|
||||
if (serializer->getType() == VariableSerializer::APCSerialize) {
|
||||
if (serializer->getType() == VariableSerializer::Type::APCSerialize) {
|
||||
p_DummyClosure dummy(NEWOBJ(c_DummyClosure));
|
||||
serializer->write(dummy);
|
||||
} else if (serializer->getType() ==
|
||||
VariableSerializer::DebuggerSerialize) {
|
||||
VariableSerializer::Type::DebuggerSerialize) {
|
||||
serializer->write("Closure");
|
||||
} else {
|
||||
throw_fatal("Serialization of Closure is not allowed");
|
||||
}
|
||||
} else if (instanceof(c_Continuation::s_cls)) {
|
||||
if (serializer->getType() == VariableSerializer::APCSerialize) {
|
||||
if (serializer->getType() == VariableSerializer::Type::APCSerialize) {
|
||||
p_DummyContinuation dummy(NEWOBJ(c_DummyContinuation));
|
||||
serializer->write(dummy);
|
||||
} else if (serializer->getType() ==
|
||||
VariableSerializer::DebuggerSerialize) {
|
||||
VariableSerializer::Type::DebuggerSerialize) {
|
||||
serializer->write("Continuation");
|
||||
} else {
|
||||
throw_fatal("Serialization of Continuation is not allowed");
|
||||
@@ -681,7 +681,7 @@ void ObjectData::serializeImpl(VariableSerializer *serializer) const {
|
||||
} else {
|
||||
CStrRef className = o_getClassName();
|
||||
Array properties = o_toArray();
|
||||
if (serializer->getType() != VariableSerializer::VarDump &&
|
||||
if (serializer->getType() != VariableSerializer::Type::VarDump &&
|
||||
className == s_PHP_Incomplete_Class) {
|
||||
Variant* cname = o_realProp(s_PHP_Incomplete_Class_Name, 0);
|
||||
if (cname && cname->isString()) {
|
||||
|
||||
@@ -156,7 +156,7 @@ static void preg_init_thread_locals() {
|
||||
std::to_string(RuntimeOption::PregRecursionLimit).c_str(),
|
||||
ini_on_update_long, &g_context->m_preg_recursion_limit);
|
||||
}
|
||||
InitFiniNode init(preg_init_thread_locals, InitFiniNode::ThreadInit);
|
||||
InitFiniNode init(preg_init_thread_locals, InitFiniNode::When::ThreadInit);
|
||||
|
||||
template<bool useSmartFree = false>
|
||||
struct FreeHelperImpl : private boost::noncopyable {
|
||||
|
||||
@@ -276,10 +276,10 @@ void register_variable(Variant &variables, char *name, CVarRef value,
|
||||
}
|
||||
}
|
||||
|
||||
enum ContextOfException {
|
||||
ReqInitException = 1,
|
||||
InvokeException,
|
||||
HandlerException,
|
||||
enum class ContextOfException {
|
||||
ReqInit = 1,
|
||||
Invoke,
|
||||
Handler,
|
||||
};
|
||||
|
||||
static void handle_exception_append_bt(std::string& errorMsg,
|
||||
@@ -301,9 +301,9 @@ static void handle_exception_helper(bool& ret,
|
||||
} catch (const Eval::DebuggerException &e) {
|
||||
throw;
|
||||
} catch (const ExitException &e) {
|
||||
if (where == ReqInitException) {
|
||||
if (where == ContextOfException::ReqInit) {
|
||||
ret = false;
|
||||
} else if (where != HandlerException &&
|
||||
} else if (where != ContextOfException::Handler &&
|
||||
!context->getExitCallback().isNull() &&
|
||||
f_is_callable(context->getExitCallback())) {
|
||||
Array stack = e.getBackTrace();
|
||||
@@ -312,7 +312,7 @@ static void handle_exception_helper(bool& ret,
|
||||
}
|
||||
} catch (const PhpFileDoesNotExistException &e) {
|
||||
ret = false;
|
||||
if (where != HandlerException) {
|
||||
if (where != ContextOfException::Handler) {
|
||||
raise_notice("%s", e.getMessage().c_str());
|
||||
} else {
|
||||
Logger::Error("%s", e.getMessage().c_str());
|
||||
@@ -342,11 +342,11 @@ static void handle_exception_helper(bool& ret,
|
||||
ret = false;
|
||||
error = true;
|
||||
errorMsg = "";
|
||||
if (where == HandlerException) {
|
||||
if (where == ContextOfException::Handler) {
|
||||
errorMsg = "Exception handler threw an exception: ";
|
||||
}
|
||||
errorMsg += e.what();
|
||||
if (where == InvokeException) {
|
||||
if (where == ContextOfException::Invoke) {
|
||||
bool handlerRet = context->onFatalError(e);
|
||||
if (handlerRet) {
|
||||
ret = oldRet;
|
||||
@@ -369,7 +369,7 @@ static void handle_exception_helper(bool& ret,
|
||||
ret = false;
|
||||
error = true;
|
||||
errorMsg = "";
|
||||
if (where == HandlerException) {
|
||||
if (where == ContextOfException::Handler) {
|
||||
errorMsg = "Exception handler threw an object exception: ";
|
||||
}
|
||||
try {
|
||||
@@ -377,7 +377,7 @@ static void handle_exception_helper(bool& ret,
|
||||
} catch (...) {
|
||||
errorMsg += "(unable to call toString())";
|
||||
}
|
||||
if (where == InvokeException) {
|
||||
if (where == ContextOfException::Invoke) {
|
||||
bool handlerRet = context->onUnhandledException(e);
|
||||
if (handlerRet) {
|
||||
ret = oldRet;
|
||||
@@ -1263,28 +1263,30 @@ void hphp_process_init() {
|
||||
static void handle_exception(bool& ret, ExecutionContext* context,
|
||||
std::string& errorMsg, ContextOfException where,
|
||||
bool& error, bool richErrorMsg) {
|
||||
assert(where == InvokeException || where == ReqInitException);
|
||||
assert(where == ContextOfException::Invoke ||
|
||||
where == ContextOfException::ReqInit);
|
||||
try {
|
||||
handle_exception_helper(ret, context, errorMsg, where, error, richErrorMsg);
|
||||
} catch (const ExitException &e) {
|
||||
// Got an ExitException during exception handling, handle
|
||||
// similarly to the case below but don't call obEndAll().
|
||||
} catch (...) {
|
||||
handle_exception_helper(ret, context, errorMsg, HandlerException, error,
|
||||
richErrorMsg);
|
||||
handle_exception_helper(ret, context, errorMsg, ContextOfException::Handler,
|
||||
error, richErrorMsg);
|
||||
context->obEndAll();
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_reqinit_exception(bool &ret, ExecutionContext *context,
|
||||
std::string &errorMsg, bool &error) {
|
||||
handle_exception(ret, context, errorMsg, ReqInitException, error, false);
|
||||
handle_exception(ret, context, errorMsg, ContextOfException::ReqInit, error,
|
||||
false);
|
||||
}
|
||||
|
||||
static void handle_invoke_exception(bool &ret, ExecutionContext *context,
|
||||
std::string &errorMsg, bool &error,
|
||||
bool richErrorMsg) {
|
||||
handle_exception(ret, context, errorMsg, InvokeException, error,
|
||||
handle_exception(ret, context, errorMsg, ContextOfException::Invoke, error,
|
||||
richErrorMsg);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace HPHP {
|
||||
IMPLEMENT_SMART_ALLOCATION(RefData);
|
||||
|
||||
RefData::~RefData() {
|
||||
assert(m_magic == kMagic);
|
||||
assert(m_magic == Magic::kMagic);
|
||||
tvAsVariant(&m_tv).~Variant();
|
||||
}
|
||||
|
||||
void RefData::dump() const {
|
||||
VariableSerializer vs(VariableSerializer::VarDump);
|
||||
VariableSerializer vs(VariableSerializer::Type::VarDump);
|
||||
String ret(vs.serialize(tvAsCVarRef(&m_tv), true));
|
||||
printf("RefData: %s", ret.c_str());
|
||||
}
|
||||
|
||||
@@ -28,19 +28,18 @@ namespace HPHP {
|
||||
* We heap allocate a RefData when we make a reference to something.
|
||||
* A Variant or TypedValue can be KindOfRef and point to a RefData,
|
||||
* but the value held here must not be KindOfRef.
|
||||
*
|
||||
*/
|
||||
class RefData {
|
||||
enum Magic : uint64_t { kMagic = 0xfacefaceb00cb00c };
|
||||
enum class Magic : uint64_t { kMagic = 0xfacefaceb00cb00c };
|
||||
public:
|
||||
enum NullInit { nullinit };
|
||||
RefData() { assert(m_magic = kMagic); }
|
||||
RefData(NullInit) {
|
||||
assert(m_magic = kMagic);
|
||||
_count = 1;
|
||||
m_tv.m_type = KindOfNull;
|
||||
RefData() {
|
||||
// intentional use of = to only assign in debug builds
|
||||
assert(static_cast<bool>(m_magic = Magic::kMagic));
|
||||
}
|
||||
RefData(DataType t, int64_t datum) {
|
||||
assert(m_magic = kMagic);
|
||||
// intentional use of = to only assign in debug builds
|
||||
assert(static_cast<bool>(m_magic = Magic::kMagic));
|
||||
init(t, datum);
|
||||
}
|
||||
~RefData();
|
||||
@@ -54,11 +53,11 @@ public:
|
||||
void dump() const;
|
||||
|
||||
const TypedValue* tv() const {
|
||||
assert(m_magic == kMagic);
|
||||
assert(m_magic == Magic::kMagic);
|
||||
return &m_tv;
|
||||
}
|
||||
TypedValue* tv() {
|
||||
assert(m_magic == kMagic);
|
||||
assert(m_magic == Magic::kMagic);
|
||||
return &m_tv;
|
||||
}
|
||||
const Variant* var() const { return (const Variant*)tv(); }
|
||||
@@ -67,7 +66,7 @@ public:
|
||||
static constexpr size_t tvOffset() { return offsetof(RefData, m_tv); }
|
||||
|
||||
void assertValid() const {
|
||||
assert(m_magic == kMagic);
|
||||
assert(m_magic == Magic::kMagic);
|
||||
}
|
||||
|
||||
// TODO: t2221110: get rid of this hack.
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace HPHP {
|
||||
*/
|
||||
|
||||
void raise_error(const std::string &msg) {
|
||||
int errnum = ErrorConstants::ERROR;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::ERROR);
|
||||
g_context->handleError(msg, errnum, false,
|
||||
RuntimeOption::CallUserHandlerOnFatals ?
|
||||
ExecutionContext::ThrowIfUnhandled :
|
||||
ExecutionContext::AlwaysThrow,
|
||||
ExecutionContext::ErrorThrowMode::IfUnhandled :
|
||||
ExecutionContext::ErrorThrowMode::Always,
|
||||
"HipHop Fatal error: ");
|
||||
}
|
||||
|
||||
@@ -47,19 +47,19 @@ void raise_error(const char *fmt, ...) {
|
||||
}
|
||||
|
||||
void raise_error_without_first_frame(const std::string &msg) {
|
||||
int errnum = ErrorConstants::ERROR;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::ERROR);
|
||||
g_context->handleError(msg, errnum, false,
|
||||
RuntimeOption::CallUserHandlerOnFatals ?
|
||||
ExecutionContext::ThrowIfUnhandled :
|
||||
ExecutionContext::AlwaysThrow,
|
||||
ExecutionContext::ErrorThrowMode::IfUnhandled :
|
||||
ExecutionContext::ErrorThrowMode::Always,
|
||||
"HipHop Fatal error: ",
|
||||
true);
|
||||
}
|
||||
|
||||
void raise_recoverable_error(const std::string &msg) {
|
||||
int errnum = ErrorConstants::RECOVERABLE_ERROR;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::RECOVERABLE_ERROR);
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::ThrowIfUnhandled,
|
||||
ExecutionContext::ErrorThrowMode::IfUnhandled,
|
||||
"HipHop Recoverable Fatal error: ");
|
||||
}
|
||||
|
||||
@@ -79,13 +79,13 @@ void raise_strict_warning(const std::string &msg) {
|
||||
(g_notice_counter++) % RuntimeOption::NoticeFrequency != 0) {
|
||||
return;
|
||||
}
|
||||
int errnum = ErrorConstants::STRICT;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::STRICT);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Strict Warning: ");
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ void raise_strict_warning(const char *fmt, ...) {
|
||||
return;
|
||||
}
|
||||
std::string msg;
|
||||
int errnum = ErrorConstants::STRICT;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::STRICT);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
va_list ap;
|
||||
@@ -105,7 +105,7 @@ void raise_strict_warning(const char *fmt, ...) {
|
||||
Util::string_vsnprintf(msg, fmt, ap);
|
||||
va_end(ap);
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Strict Warning: ");
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ void raise_warning(const std::string &msg) {
|
||||
(g_warning_counter++) % RuntimeOption::WarningFrequency != 0) {
|
||||
return;
|
||||
}
|
||||
int errnum = ErrorConstants::WARNING;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::WARNING);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Warning: ");
|
||||
}
|
||||
|
||||
@@ -132,9 +132,9 @@ void raise_warning(const char *fmt, ...) {
|
||||
return;
|
||||
}
|
||||
std::string msg;
|
||||
int errnum = ErrorConstants::WARNING;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::WARNING);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
va_list ap;
|
||||
@@ -142,13 +142,15 @@ void raise_warning(const char *fmt, ...) {
|
||||
Util::string_vsnprintf(msg, fmt, ap);
|
||||
va_end(ap);
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Warning: ");
|
||||
}
|
||||
|
||||
void raise_debugging(const std::string &msg) {
|
||||
g_context->handleError(msg, ErrorConstants::WARNING, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
g_context->handleError(msg,
|
||||
static_cast<int>(ErrorConstants::ErrorModes::WARNING),
|
||||
true,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Warning: ");
|
||||
}
|
||||
|
||||
@@ -166,13 +168,13 @@ void raise_notice(const std::string &msg) {
|
||||
(g_notice_counter++) % RuntimeOption::NoticeFrequency != 0) {
|
||||
return;
|
||||
}
|
||||
int errnum = ErrorConstants::NOTICE;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::NOTICE);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Notice: ");
|
||||
}
|
||||
|
||||
@@ -182,9 +184,9 @@ void raise_notice(const char *fmt, ...) {
|
||||
return;
|
||||
}
|
||||
std::string msg;
|
||||
int errnum = ErrorConstants::NOTICE;
|
||||
int errnum = static_cast<int>(ErrorConstants::ErrorModes::NOTICE);
|
||||
if (!g_context->errorNeedsHandling(errnum, true,
|
||||
ExecutionContext::NeverThrow)) {
|
||||
ExecutionContext::ErrorThrowMode::Never)) {
|
||||
return;
|
||||
}
|
||||
va_list ap;
|
||||
@@ -192,7 +194,7 @@ void raise_notice(const char *fmt, ...) {
|
||||
Util::string_vsnprintf(msg, fmt, ap);
|
||||
va_end(ap);
|
||||
g_context->handleError(msg, errnum, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Notice: ");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace HPHP {
|
||||
|
||||
class ErrorConstants {
|
||||
public:
|
||||
enum ErrorModes {
|
||||
enum class ErrorModes {
|
||||
ERROR = 1,
|
||||
WARNING = 2,
|
||||
PARSE = 4, // not supported
|
||||
|
||||
@@ -63,7 +63,8 @@ bool RuntimeOption::NoSilencer = false;
|
||||
bool RuntimeOption::EnableApplicationLog = true;
|
||||
bool RuntimeOption::CallUserHandlerOnFatals = true;
|
||||
bool RuntimeOption::ThrowExceptionOnBadMethodCall = true;
|
||||
int RuntimeOption::RuntimeErrorReportingLevel = ErrorConstants::HPHP_ALL;
|
||||
int RuntimeOption::RuntimeErrorReportingLevel =
|
||||
static_cast<int>(ErrorConstants::ErrorModes::HPHP_ALL);
|
||||
|
||||
std::string RuntimeOption::ServerUser;
|
||||
|
||||
@@ -327,7 +328,8 @@ bool RuntimeOption::ForceConstLoadToAPC = true;
|
||||
std::string RuntimeOption::ApcPrimeLibrary;
|
||||
int RuntimeOption::ApcLoadThread = 1;
|
||||
std::set<std::string> RuntimeOption::ApcCompletionKeys;
|
||||
RuntimeOption::ApcTableTypes RuntimeOption::ApcTableType = ApcConcurrentTable;
|
||||
RuntimeOption::ApcTableTypes RuntimeOption::ApcTableType =
|
||||
ApcTableTypes::ApcConcurrentTable;
|
||||
bool RuntimeOption::EnableApcSerialize = true;
|
||||
time_t RuntimeOption::ApcKeyMaturityThreshold = 20;
|
||||
size_t RuntimeOption::ApcMaximumCapacity = 0;
|
||||
@@ -605,7 +607,8 @@ void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */,
|
||||
NoSilencer = logger["NoSilencer"].getBool();
|
||||
EnableApplicationLog = logger["ApplicationLog"].getBool(true);
|
||||
RuntimeErrorReportingLevel =
|
||||
logger["RuntimeErrorReportingLevel"].getInt32(ErrorConstants::HPHP_ALL);
|
||||
logger["RuntimeErrorReportingLevel"]
|
||||
.getInt32(static_cast<int>(ErrorConstants::ErrorModes::HPHP_ALL));
|
||||
|
||||
AccessLogDefaultFormat = logger["AccessLogDefaultFormat"].
|
||||
getString("%h %l %u %t \"%r\" %>s %b");
|
||||
@@ -835,7 +838,7 @@ void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */,
|
||||
|
||||
string apcTableType = apc["TableType"].getString("concurrent");
|
||||
if (strcasecmp(apcTableType.c_str(), "concurrent") == 0) {
|
||||
ApcTableType = ApcConcurrentTable;
|
||||
ApcTableType = ApcTableTypes::ApcConcurrentTable;
|
||||
} else {
|
||||
throw InvalidArgumentException("apc table type",
|
||||
"Invalid table type");
|
||||
@@ -937,7 +940,7 @@ void RuntimeOption::Load(Hdf &config, StringVec *overwrites /* = NULL */,
|
||||
for (Hdf hdf = satellites.firstChild(); hdf.exists(); hdf = hdf.next()) {
|
||||
SatelliteServerInfoPtr satellite(new SatelliteServerInfo(hdf));
|
||||
SatelliteServerInfos.push_back(satellite);
|
||||
if (satellite->getType() == SatelliteServer::KindOfRPCServer) {
|
||||
if (satellite->getType() == SatelliteServer::Type::KindOfRPCServer) {
|
||||
XboxPassword = satellite->getPassword();
|
||||
XboxPasswords = satellite->getPasswords();
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
static std::string ApcPrimeLibrary;
|
||||
static int ApcLoadThread;
|
||||
static std::set<std::string> ApcCompletionKeys;
|
||||
enum ApcTableTypes {
|
||||
enum class ApcTableTypes {
|
||||
ApcConcurrentTable
|
||||
};
|
||||
static ApcTableTypes ApcTableType;
|
||||
|
||||
@@ -327,9 +327,9 @@ bool AccessLog::genField(std::ostringstream &out, const char* &format,
|
||||
{
|
||||
const char *method = nullptr;
|
||||
switch (transport->getMethod()) {
|
||||
case Transport::GET: method = "GET"; break;
|
||||
case Transport::POST: method = "POST"; break;
|
||||
case Transport::HEAD: method = "HEAD"; break;
|
||||
case Transport::Method::GET: method = "GET"; break;
|
||||
case Transport::Method::POST: method = "POST"; break;
|
||||
case Transport::Method::HEAD: method = "HEAD"; break;
|
||||
default: break;
|
||||
}
|
||||
if (!method) return false;
|
||||
|
||||
@@ -621,13 +621,14 @@ bool AdminRequestHandler::handleCheckRequest(const std::string &cmd,
|
||||
bool AdminRequestHandler::handleStatusRequest(const std::string &cmd,
|
||||
Transport *transport) {
|
||||
if (cmd == "status.xml") {
|
||||
return send_status(transport, ServerStats::XML, "application/xml");
|
||||
return send_status(transport, ServerStats::Format::XML, "application/xml");
|
||||
}
|
||||
if (cmd == "status.json") {
|
||||
return send_status(transport, ServerStats::JSON, "application/json");
|
||||
return send_status(transport, ServerStats::Format::JSON,
|
||||
"application/json");
|
||||
}
|
||||
if (cmd == "status.html" || cmd == "status.htm") {
|
||||
return send_status(transport, ServerStats::HTML, "text/html");
|
||||
return send_status(transport, ServerStats::Format::HTML, "text/html");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -691,16 +692,17 @@ bool AdminRequestHandler::handleStatsRequest(const std::string &cmd,
|
||||
return true;
|
||||
}
|
||||
if (cmd == "stats.xml") {
|
||||
return send_report(transport, ServerStats::XML, "application/xml");
|
||||
return send_report(transport, ServerStats::Format::XML, "application/xml");
|
||||
}
|
||||
if (cmd == "stats.json") {
|
||||
return send_report(transport, ServerStats::JSON, "application/json");
|
||||
return send_report(transport, ServerStats::Format::JSON,
|
||||
"application/json");
|
||||
}
|
||||
if (cmd == "stats.kvp") {
|
||||
return send_report(transport, ServerStats::KVP, "text/plain");
|
||||
return send_report(transport, ServerStats::Format::KVP, "text/plain");
|
||||
}
|
||||
if (cmd == "stats.html" || cmd == "stats.htm") {
|
||||
return send_report(transport, ServerStats::HTML, "text/html");
|
||||
return send_report(transport, ServerStats::Format::HTML, "text/html");
|
||||
}
|
||||
|
||||
if (cmd == "stats.xsl") {
|
||||
|
||||
@@ -170,7 +170,7 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
|
||||
string contentType = transport->getHeader("Content-Type");
|
||||
string contentLength = transport->getHeader("Content-Length");
|
||||
// $_POST and $_REQUEST
|
||||
if (transport->getMethod() == Transport::POST) {
|
||||
if (transport->getMethod() == Transport::Method::POST) {
|
||||
bool needDelete = false;
|
||||
int size = 0;
|
||||
const void *data = transport->getPostData(size);
|
||||
@@ -388,9 +388,9 @@ void HttpProtocol::PrepareSystemVariables(Transport *transport,
|
||||
server.set(s_SERVER_ADMIN, empty_string);
|
||||
server.set(s_SERVER_SIGNATURE, empty_string);
|
||||
switch (transport->getMethod()) {
|
||||
case Transport::GET: server.set(s_REQUEST_METHOD, s_GET); break;
|
||||
case Transport::HEAD: server.set(s_REQUEST_METHOD, s_HEAD); break;
|
||||
case Transport::POST:
|
||||
case Transport::Method::GET: server.set(s_REQUEST_METHOD, s_GET); break;
|
||||
case Transport::Method::HEAD: server.set(s_REQUEST_METHOD, s_HEAD); break;
|
||||
case Transport::Method::POST:
|
||||
if (transport->getExtendedMethod() == nullptr) {
|
||||
server.set(s_REQUEST_METHOD, s_POST);
|
||||
} else {
|
||||
@@ -669,7 +669,7 @@ bool HttpProtocol::ProxyRequest(Transport *transport, bool force,
|
||||
|
||||
int size = 0;
|
||||
const char *data = nullptr;
|
||||
if (transport->getMethod() == Transport::POST) {
|
||||
if (transport->getMethod() == Transport::Method::POST) {
|
||||
data = (const char *)transport->getPostData(size);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,17 +76,17 @@ void HttpRequestHandler::sendStaticContent(Transport *transport,
|
||||
|
||||
time_t base = time(nullptr);
|
||||
if (RuntimeOption::ExpiresActive) {
|
||||
time_t expires = base + RuntimeOption::ExpiresDefault;
|
||||
time_t exp = base + RuntimeOption::ExpiresDefault;
|
||||
char age[20];
|
||||
snprintf(age, sizeof(age), "max-age=%d", RuntimeOption::ExpiresDefault);
|
||||
transport->addHeader("Cache-Control", age);
|
||||
transport->addHeader("Expires",
|
||||
DateTime(expires, true).toString(DateTime::HttpHeader).c_str());
|
||||
DateTime(exp, true).toString(DateTime::DateFormat::HttpHeader).c_str());
|
||||
}
|
||||
|
||||
if (mtime) {
|
||||
transport->addHeader("Last-Modified",
|
||||
DateTime(mtime, true).toString(DateTime::HttpHeader).c_str());
|
||||
DateTime(mtime, true).toString(DateTime::DateFormat::HttpHeader).c_str());
|
||||
}
|
||||
transport->addHeader("Accept-Ranges", "bytes");
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ HttpServer::HttpServer(void *sslCTX /* = NULL */)
|
||||
SatelliteServerInfoPtr info = RuntimeOption::SatelliteServerInfos[i];
|
||||
SatelliteServerPtr satellite = SatelliteServer::Create(info);
|
||||
if (satellite) {
|
||||
if (info->getType() == SatelliteServer::KindOfDanglingPageServer) {
|
||||
if (info->getType() == SatelliteServer::Type::KindOfDanglingPageServer) {
|
||||
m_danglings.push_back(satellite);
|
||||
} else {
|
||||
m_satellites.push_back(satellite);
|
||||
@@ -133,7 +133,7 @@ HttpServer::HttpServer(void *sslCTX /* = NULL */)
|
||||
|
||||
if (!RuntimeOption::StartupDocument.empty()) {
|
||||
Hdf hdf;
|
||||
hdf["cmd"] = Transport::GET;
|
||||
hdf["cmd"] = static_cast<int>(Transport::Method::GET);
|
||||
hdf["url"] = RuntimeOption::StartupDocument;
|
||||
hdf["remote_host"] = RuntimeOption::ServerIP;
|
||||
|
||||
|
||||
@@ -172,12 +172,13 @@ LibEventServer::LibEventServer(const std::string &address, int port,
|
||||
}
|
||||
|
||||
LibEventServer::~LibEventServer() {
|
||||
assert(getStatus() == STOPPED || getStatus() == STOPPING ||
|
||||
getStatus() == NOT_YET_STARTED);
|
||||
assert(getStatus() == RunStatus::STOPPED ||
|
||||
getStatus() == RunStatus::STOPPING ||
|
||||
getStatus() == RunStatus::NOT_YET_STARTED);
|
||||
// We can't free event base when server is still working on it.
|
||||
// This will cause a leak with event base, but normally this happens when
|
||||
// process exits, so we're probably fine.
|
||||
if (getStatus() != STOPPING) {
|
||||
if (getStatus() != RunStatus::STOPPING) {
|
||||
event_base_free(m_eventBase);
|
||||
}
|
||||
}
|
||||
@@ -203,7 +204,7 @@ int LibEventServer::getLibEventConnectionCount() {
|
||||
}
|
||||
|
||||
void LibEventServer::start() {
|
||||
if (getStatus() == RUNNING) return;
|
||||
if (getStatus() == RunStatus::RUNNING) return;
|
||||
|
||||
if (getAcceptSocket() != 0) {
|
||||
throw FailedToListenException(m_address, m_port);
|
||||
@@ -220,7 +221,7 @@ void LibEventServer::start() {
|
||||
Logger::Info("Listen on ssl port %d",m_port_ssl);
|
||||
}
|
||||
|
||||
setStatus(RUNNING);
|
||||
setStatus(RunStatus::RUNNING);
|
||||
m_dispatcher.start();
|
||||
m_dispatcherThread.start();
|
||||
m_timeoutThread.start();
|
||||
@@ -255,7 +256,7 @@ void LibEventServer::dispatch() {
|
||||
event_base_set(m_eventBase, &m_eventStop);
|
||||
event_add(&m_eventStop, nullptr);
|
||||
|
||||
while (getStatus() != STOPPED) {
|
||||
while (getStatus() != RunStatus::STOPPED) {
|
||||
event_base_loop(m_eventBase, EVLOOP_ONCE);
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ void LibEventServer::dispatch() {
|
||||
|
||||
void LibEventServer::stop() {
|
||||
Lock lock(m_mutex);
|
||||
if (getStatus() != RUNNING || m_server == nullptr) return;
|
||||
if (getStatus() != RunStatus::RUNNING || m_server == nullptr) return;
|
||||
|
||||
#define SHUT_FBLISTEN 3
|
||||
/*
|
||||
@@ -311,13 +312,13 @@ void LibEventServer::stop() {
|
||||
}
|
||||
|
||||
// inform LibEventServer::onRequest() to stop queuing
|
||||
setStatus(STOPPING);
|
||||
setStatus(RunStatus::STOPPING);
|
||||
|
||||
// stop JobQueue processing
|
||||
m_dispatcher.stop();
|
||||
|
||||
// stop event loop
|
||||
setStatus(STOPPED);
|
||||
setStatus(RunStatus::STOPPED);
|
||||
if (write(m_pipeStop.getIn(), "", 1) < 0) {
|
||||
// an error occured but we're in shutdown already, so ignore
|
||||
}
|
||||
@@ -386,7 +387,7 @@ void LibEventServer::onRequest(struct evhttp_request *request) {
|
||||
evhttp_connection_set_timeout(request->evcon,
|
||||
RuntimeOption::ConnectionTimeoutSeconds);
|
||||
}
|
||||
if (getStatus() == RUNNING) {
|
||||
if (getStatus() == RunStatus::RUNNING) {
|
||||
m_dispatcher.enqueue(LibEventJobPtr(new LibEventJob(request)));
|
||||
} else {
|
||||
Logger::Error("throwing away one new request while shutting down");
|
||||
|
||||
@@ -55,20 +55,20 @@ LibEventTransport::LibEventTransport(LibEventServer *server,
|
||||
|
||||
switch (m_request->type) {
|
||||
case EVHTTP_REQ_GET:
|
||||
m_method = Transport::GET;
|
||||
m_method = Transport::Method::GET;
|
||||
m_requestSize += 3;
|
||||
break;
|
||||
case EVHTTP_REQ_POST:
|
||||
m_method = Transport::POST;
|
||||
m_method = Transport::Method::POST;
|
||||
m_requestSize += 4;
|
||||
break;
|
||||
case EVHTTP_REQ_HEAD:
|
||||
m_method = Transport::HEAD;
|
||||
m_method = Transport::Method::HEAD;
|
||||
m_requestSize += 4;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
m_method = Transport::UnknownMethod;
|
||||
m_method = Transport::Method::Unknown;
|
||||
break;
|
||||
}
|
||||
m_extended_method = m_request->ext_method;
|
||||
@@ -256,7 +256,7 @@ void LibEventTransport::removeRequestHeaderImpl(const char *name) {
|
||||
}
|
||||
|
||||
bool LibEventTransport::isServerStopping() {
|
||||
return m_server->getStatus() == Server::STOPPED;
|
||||
return m_server->getStatus() == Server::RunStatus::STOPPED;
|
||||
}
|
||||
|
||||
void LibEventTransport::sendImpl(const void *data, int size, int code,
|
||||
@@ -266,7 +266,7 @@ void LibEventTransport::sendImpl(const void *data, int size, int code,
|
||||
assert(!m_sendStarted || chunked);
|
||||
|
||||
if (chunked) {
|
||||
assert(m_method != HEAD);
|
||||
assert(m_method != Method::HEAD);
|
||||
evbuffer *chunk = evbuffer_new();
|
||||
evbuffer_add(chunk, data, size);
|
||||
/*
|
||||
@@ -278,7 +278,7 @@ void LibEventTransport::sendImpl(const void *data, int size, int code,
|
||||
m_server->onChunkedResponse(m_workerId, m_request, code, chunk,
|
||||
!m_sendStarted);
|
||||
} else {
|
||||
if (m_method != HEAD) {
|
||||
if (m_method != Method::HEAD) {
|
||||
evbuffer_add(m_request->output_buffer, data, size);
|
||||
} else if (!evhttp_find_header(m_request->output_headers,
|
||||
"Content-Length")) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
: m_refCount(0), m_done(false), m_code(0) {
|
||||
|
||||
gettime(CLOCK_MONOTONIC, &m_queueTime);
|
||||
m_threadType = PageletThread;
|
||||
m_threadType = ThreadType::PageletThread;
|
||||
|
||||
m_url.append(url.data(), url.size());
|
||||
m_remoteHost.append(remoteHost.data(), remoteHost.size());
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
return m_postData.data();
|
||||
}
|
||||
virtual Method getMethod() {
|
||||
return m_get ? Transport::GET : Transport::POST;
|
||||
return m_get ? Transport::Method::GET : Transport::Method::POST;
|
||||
}
|
||||
virtual std::string getHeader(const char *name) {
|
||||
assert(name && *name);
|
||||
|
||||
@@ -36,7 +36,7 @@ void ReplayTransport::recordInput(Transport* transport, const char *filename) {
|
||||
snprintf(buf, sizeof(buf), "%u", Process::GetThreadPid());
|
||||
hdf["tpid"] = string(buf);
|
||||
|
||||
hdf["cmd"] = transport->getMethod();
|
||||
hdf["cmd"] = static_cast<int>(transport->getMethod());
|
||||
hdf["url"] = transport->getUrl();
|
||||
hdf["remote_host"] = transport->getRemoteHost();
|
||||
hdf["remote_port"] = transport->getRemotePort();
|
||||
|
||||
@@ -36,7 +36,7 @@ RPCRequestHandler::RPCRequestHandler(bool info /* = true */)
|
||||
: m_requestsSinceReset(0),
|
||||
m_reset(false),
|
||||
m_logResets(info),
|
||||
m_returnEncodeType(Json) {
|
||||
m_returnEncodeType(ReturnEncodeType::Json) {
|
||||
initState();
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ void RPCRequestHandler::handleRequest(Transport *transport) {
|
||||
// return encoding type
|
||||
ReturnEncodeType returnEncodeType = m_returnEncodeType;
|
||||
if (transport->getParam("return") == "serialize") {
|
||||
returnEncodeType = Serialize;
|
||||
returnEncodeType = ReturnEncodeType::Serialize;
|
||||
}
|
||||
|
||||
// resolve virtual host
|
||||
@@ -153,11 +153,11 @@ void RPCRequestHandler::handleRequest(Transport *transport) {
|
||||
|
||||
// set thread type
|
||||
switch (m_serverInfo->getType()) {
|
||||
case SatelliteServer::KindOfRPCServer:
|
||||
transport->setThreadType(Transport::RpcThread);
|
||||
case SatelliteServer::Type::KindOfRPCServer:
|
||||
transport->setThreadType(Transport::ThreadType::RpcThread);
|
||||
break;
|
||||
case SatelliteServer::KindOfXboxServer:
|
||||
transport->setThreadType(Transport::XboxThread);
|
||||
case SatelliteServer::Type::KindOfXboxServer:
|
||||
transport->setThreadType(Transport::ThreadType::XboxThread);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -296,11 +296,12 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport,
|
||||
String response;
|
||||
switch (output) {
|
||||
case 0: {
|
||||
assert(returnEncodeType == Json ||
|
||||
returnEncodeType == Serialize);
|
||||
assert(returnEncodeType == ReturnEncodeType::Json ||
|
||||
returnEncodeType == ReturnEncodeType::Serialize);
|
||||
try {
|
||||
response = (returnEncodeType == Json) ? f_json_encode(funcRet)
|
||||
: f_serialize(funcRet);
|
||||
response = (returnEncodeType == ReturnEncodeType::Json) ?
|
||||
f_json_encode(funcRet) :
|
||||
f_serialize(funcRet);
|
||||
} catch (...) {
|
||||
serializeFailed = true;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ DECLARE_BOOST_TYPES(SatelliteServerInfo);
|
||||
|
||||
class RPCRequestHandler : public RequestHandler {
|
||||
public:
|
||||
enum ReturnEncodeType {
|
||||
enum class ReturnEncodeType {
|
||||
Json = 1,
|
||||
Serialize = 2,
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ SatelliteServerInfo::SatelliteServerInfo(Hdf hdf) {
|
||||
|
||||
string type = hdf["Type"].getString();
|
||||
if (type == "InternalPageServer") {
|
||||
m_type = SatelliteServer::KindOfInternalPageServer;
|
||||
m_type = SatelliteServer::Type::KindOfInternalPageServer;
|
||||
vector<string> urls;
|
||||
hdf["URLs"].get(urls);
|
||||
for (unsigned int i = 0; i < urls.size(); i++) {
|
||||
@@ -60,12 +60,12 @@ SatelliteServerInfo::SatelliteServerInfo(Hdf hdf) {
|
||||
InternalURLs.insert(m_urls.begin(), m_urls.end());
|
||||
}
|
||||
} else if (type == "DanglingPageServer") {
|
||||
m_type = SatelliteServer::KindOfDanglingPageServer;
|
||||
m_type = SatelliteServer::Type::KindOfDanglingPageServer;
|
||||
DanglingServerPort = m_port;
|
||||
} else if (type == "RPCServer") {
|
||||
m_type = SatelliteServer::KindOfRPCServer;
|
||||
m_type = SatelliteServer::Type::KindOfRPCServer;
|
||||
} else {
|
||||
m_type = SatelliteServer::UnknownType;
|
||||
m_type = SatelliteServer::Type::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,16 +180,16 @@ SatelliteServerPtr SatelliteServer::Create(SatelliteServerInfoPtr info) {
|
||||
SatelliteServerPtr satellite;
|
||||
if (info->getPort()) {
|
||||
switch (info->getType()) {
|
||||
case KindOfInternalPageServer:
|
||||
case Type::KindOfInternalPageServer:
|
||||
satellite = SatelliteServerPtr(new InternalPageServer(info));
|
||||
break;
|
||||
case KindOfDanglingPageServer:
|
||||
case Type::KindOfDanglingPageServer:
|
||||
satellite = SatelliteServerPtr(new DanglingPageServer(info));
|
||||
break;
|
||||
case KindOfRPCServer:
|
||||
case Type::KindOfRPCServer:
|
||||
satellite = SatelliteServerPtr(new RPCServer(info));
|
||||
break;
|
||||
case KindOfXboxServer:
|
||||
case Type::KindOfXboxServer:
|
||||
satellite = SatelliteServerPtr(new RPCServer(info));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -28,8 +28,8 @@ DECLARE_BOOST_TYPES(SatelliteServerInfo);
|
||||
DECLARE_BOOST_TYPES(SatelliteServer);
|
||||
class SatelliteServer {
|
||||
public:
|
||||
enum Type {
|
||||
UnknownType,
|
||||
enum class Type {
|
||||
Unknown,
|
||||
|
||||
KindOfInternalPageServer, // handles restricted URLs
|
||||
KindOfDanglingPageServer, // handles old version requests during shutdown
|
||||
|
||||
@@ -51,7 +51,7 @@ void Server::InstallStopSignalHandlers(ServerPtr server) {
|
||||
Server::Server(const std::string &address, int port, int threadCount)
|
||||
: m_address(address), m_port(port), m_threadCount(threadCount),
|
||||
m_urlChecker(SatelliteServerInfo::checkMainURL),
|
||||
m_status(NOT_YET_STARTED) {
|
||||
m_status(RunStatus::NOT_YET_STARTED) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -106,7 +106,7 @@ typedef std::function<bool(const std::string&)> URLChecker;
|
||||
*/
|
||||
class Server {
|
||||
public:
|
||||
enum RunStatus {
|
||||
enum class RunStatus {
|
||||
NOT_YET_STARTED = 0,
|
||||
RUNNING,
|
||||
STOPPING,
|
||||
|
||||
@@ -706,7 +706,7 @@ void ServerStats::Report(string &output, Format format,
|
||||
const list<TimeSlot*> &slots,
|
||||
const std::string &prefix) {
|
||||
std::ostringstream out;
|
||||
if (format == KVP) {
|
||||
if (format == Format::KVP) {
|
||||
bool first = true;
|
||||
for (list<TimeSlot*>::const_iterator iter = slots.begin();
|
||||
iter != slots.end(); ++iter) {
|
||||
@@ -751,12 +751,12 @@ void ServerStats::Report(string &output, Format format,
|
||||
|
||||
} else {
|
||||
Writer *w;
|
||||
if (format == XML) {
|
||||
if (format == Format::XML) {
|
||||
w = new XMLWriter(out);
|
||||
} else if (format == HTML) {
|
||||
} else if (format == Format::HTML) {
|
||||
w = new HTMLWriter(out);
|
||||
} else {
|
||||
assert(format == JSON);
|
||||
assert(format == Format::JSON);
|
||||
w = new JSONWriter(out);
|
||||
}
|
||||
|
||||
@@ -833,12 +833,12 @@ static std::string format_duration(timeval &duration) {
|
||||
void ServerStats::ReportStatus(std::string &output, Format format) {
|
||||
std::ostringstream out;
|
||||
Writer *w;
|
||||
if (format == XML) {
|
||||
if (format == Format::XML) {
|
||||
w = new XMLWriter(out);
|
||||
} else if (format == HTML) {
|
||||
} else if (format == Format::HTML) {
|
||||
w = new HTMLWriter(out);
|
||||
} else {
|
||||
assert(format == JSON);
|
||||
assert(format == Format::JSON);
|
||||
w = new JSONWriter(out);
|
||||
}
|
||||
|
||||
@@ -893,10 +893,10 @@ void ServerStats::ReportStatus(std::string &output, Format format) {
|
||||
|
||||
const char *mode = "(unknown)";
|
||||
switch (ts.m_mode) {
|
||||
case Idling: mode = "idle"; break;
|
||||
case Processing: mode = "process"; break;
|
||||
case Writing: mode = "writing"; break;
|
||||
case PostProcessing: mode = "psp"; break;
|
||||
case ThreadMode::Idling: mode = "idle"; break;
|
||||
case ThreadMode::Processing: mode = "process"; break;
|
||||
case ThreadMode::Writing: mode = "writing"; break;
|
||||
case ThreadMode::PostProcessing: mode = "psp"; break;
|
||||
default: assert(false);
|
||||
}
|
||||
|
||||
@@ -982,7 +982,8 @@ Array ServerStats::EndNetworkProfile() {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ServerStats::ThreadStatus::ThreadStatus()
|
||||
: m_requestCount(0), m_writeBytes(0), m_mode(Idling), m_ioInProcess(false) {
|
||||
: m_requestCount(0), m_writeBytes(0), m_mode(ThreadMode::Idling),
|
||||
m_ioInProcess(false) {
|
||||
m_threadId = Process::GetThreadId();
|
||||
memset(&m_start, 0, sizeof(m_start));
|
||||
memset(&m_done, 0, sizeof(m_done));
|
||||
@@ -1071,7 +1072,7 @@ void ServerStats::logPage(const string &url, int code) {
|
||||
m_max = now;
|
||||
}
|
||||
|
||||
m_threadStatus.m_mode = Idling;
|
||||
m_threadStatus.m_mode = ThreadMode::Idling;
|
||||
gettimeofday(&m_threadStatus.m_done, 0);
|
||||
}
|
||||
|
||||
@@ -1123,7 +1124,7 @@ void ServerStats::startRequest(const char *url, const char *clientIP,
|
||||
m_threadStatus.m_mm = ThreadInfo::s_threadInfo->m_mm;
|
||||
gettimeofday(&m_threadStatus.m_start, 0);
|
||||
memset(&m_threadStatus.m_done, 0, sizeof(m_threadStatus.m_done));
|
||||
m_threadStatus.m_mode = Processing;
|
||||
m_threadStatus.m_mode = ThreadMode::Processing;
|
||||
m_threadStatus.m_ioStatuses.clear();
|
||||
|
||||
*m_threadStatus.m_ioLogicalName = 0;
|
||||
|
||||
@@ -29,14 +29,14 @@ namespace HPHP {
|
||||
|
||||
class ServerStats {
|
||||
public:
|
||||
enum Format {
|
||||
enum class Format {
|
||||
XML,
|
||||
JSON,
|
||||
KVP,
|
||||
HTML
|
||||
};
|
||||
|
||||
enum ThreadMode {
|
||||
enum class ThreadMode {
|
||||
Idling,
|
||||
Processing,
|
||||
Writing,
|
||||
@@ -206,7 +206,7 @@ public:
|
||||
TRACK_MEMORY = 0x00000001,
|
||||
TRACK_HWINST = 0x00000002,
|
||||
};
|
||||
ServerStatsHelper(const char *section, uint32_t track = 0);
|
||||
explicit ServerStatsHelper(const char *section, uint32_t track = 0);
|
||||
~ServerStatsHelper();
|
||||
|
||||
private:
|
||||
@@ -227,7 +227,8 @@ private:
|
||||
*/
|
||||
class IOStatusHelper {
|
||||
public:
|
||||
IOStatusHelper(const char *name, const char *address = nullptr, int port = 0);
|
||||
explicit IOStatusHelper(const char *name, const char *address = nullptr,
|
||||
int port = 0);
|
||||
~IOStatusHelper();
|
||||
|
||||
private:
|
||||
|
||||
@@ -30,7 +30,8 @@ IMPLEMENT_THREAD_LOCAL_NO_CHECK(string, SourceRootInfo::s_path);
|
||||
IMPLEMENT_THREAD_LOCAL_NO_CHECK(string, SourceRootInfo::s_phproot);
|
||||
|
||||
SourceRootInfo::SourceRootInfo(const char *host)
|
||||
: m_sandboxCond(RuntimeOption::SandboxMode ? SandboxOn : SandboxOff) {
|
||||
: m_sandboxCond(RuntimeOption::SandboxMode ? SandboxCondition::On :
|
||||
SandboxCondition::Off) {
|
||||
s_path.destroy();
|
||||
s_phproot.destroy();
|
||||
if (!sandboxOn()) return;
|
||||
@@ -39,7 +40,7 @@ SourceRootInfo::SourceRootInfo(const char *host)
|
||||
RuntimeOption::SandboxPattern.size(),
|
||||
AttachLiteral), host, matches);
|
||||
if (!same(r, 1)) {
|
||||
m_sandboxCond = SandboxOff;
|
||||
m_sandboxCond = SandboxCondition::Off;
|
||||
return;
|
||||
}
|
||||
if (RuntimeOption::SandboxFromCommonRoot) {
|
||||
@@ -62,7 +63,8 @@ SourceRootInfo::SourceRootInfo(const char *host)
|
||||
|
||||
SourceRootInfo::SourceRootInfo(const std::string &user,
|
||||
const std::string &sandbox)
|
||||
: m_sandboxCond(RuntimeOption::SandboxMode ? SandboxOn : SandboxOff) {
|
||||
: m_sandboxCond(RuntimeOption::SandboxMode ? SandboxCondition::On :
|
||||
SandboxCondition::Off) {
|
||||
s_path.destroy();
|
||||
s_phproot.destroy();
|
||||
if (!sandboxOn()) return;
|
||||
@@ -103,7 +105,7 @@ void SourceRootInfo::createFromUserConfig() {
|
||||
if (!RuntimeOption::SandboxFallback.empty()) {
|
||||
homePath = String(RuntimeOption::SandboxFallback) + "/" + m_user + "/";
|
||||
if (stat(homePath.c_str(), &hstat) != 0) {
|
||||
m_sandboxCond = SandboxOff;
|
||||
m_sandboxCond = SandboxCondition::Off;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -142,7 +144,7 @@ void SourceRootInfo::createFromUserConfig() {
|
||||
}
|
||||
}
|
||||
if (sp.isNull()) {
|
||||
m_sandboxCond = SandboxError;
|
||||
m_sandboxCond = SandboxCondition::Error;
|
||||
return;
|
||||
}
|
||||
if (sp.charAt(0) == '/') {
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
std::string path() const;
|
||||
|
||||
bool sandboxOn() const {
|
||||
return m_sandboxCond == SandboxOn;
|
||||
return m_sandboxCond == SandboxCondition::On;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
bool error() const {
|
||||
return m_sandboxCond == SandboxError;
|
||||
return m_sandboxCond == SandboxCondition::Error;
|
||||
}
|
||||
void handleError(Transport *t);
|
||||
static const std::string &GetCurrentSourceRoot() {
|
||||
@@ -65,10 +65,10 @@ private:
|
||||
String m_user;
|
||||
String m_sandbox;
|
||||
String m_path;
|
||||
enum SandboxCondition {
|
||||
SandboxOn,
|
||||
SandboxError,
|
||||
SandboxOff
|
||||
enum class SandboxCondition {
|
||||
On,
|
||||
Error,
|
||||
Off
|
||||
} m_sandboxCond;
|
||||
Array m_serverVars;
|
||||
static DECLARE_THREAD_LOCAL_NO_CHECK(std::string, s_path);
|
||||
|
||||
@@ -42,7 +42,8 @@ Transport::Transport()
|
||||
m_responseSize(0), m_responseTotalSize(0), m_responseSentSize(0),
|
||||
m_flushTimeUs(0), m_sendContentType(true),
|
||||
m_compression(true), m_compressor(nullptr), m_isSSL(false),
|
||||
m_compressionDecision(NotDecidedYet), m_threadType(RequestThread) {
|
||||
m_compressionDecision(CompressionDecision::NotDecidedYet),
|
||||
m_threadType(ThreadType::RequestThread) {
|
||||
memset(&m_queueTime, 0, sizeof(m_queueTime));
|
||||
memset(&m_wallTime, 0, sizeof(m_wallTime));
|
||||
memset(&m_cpuTime, 0, sizeof(m_cpuTime));
|
||||
@@ -76,15 +77,15 @@ void Transport::onRequestStart(const timespec &queueTime) {
|
||||
|
||||
const char *Transport::getMethodName() {
|
||||
switch (getMethod()) {
|
||||
case GET: return "GET";
|
||||
case HEAD: return "HEAD";
|
||||
case POST: {
|
||||
const char *m = getExtendedMethod();
|
||||
return m ? m : "POST";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case Method::GET: return "GET";
|
||||
case Method::HEAD: return "HEAD";
|
||||
case Method::POST: {
|
||||
const char *m = getExtendedMethod();
|
||||
return m ? m : "POST";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -206,9 +207,10 @@ void Transport::parsePostParams() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Transport::paramExists(const char *name, Method method /* = GET */) {
|
||||
bool Transport::paramExists(const char *name,
|
||||
Method method /* = Method::GET */) {
|
||||
assert(name && *name);
|
||||
if (method == GET || method == AUTO) {
|
||||
if (method == Method::GET || method == Method::AUTO) {
|
||||
if (m_url == nullptr) {
|
||||
parseGetParams();
|
||||
}
|
||||
@@ -217,7 +219,7 @@ bool Transport::paramExists(const char *name, Method method /* = GET */) {
|
||||
}
|
||||
}
|
||||
|
||||
if (method == POST || method == AUTO) {
|
||||
if (method == Method::POST || method == Method::AUTO) {
|
||||
if (!m_postDataParsed) {
|
||||
parsePostParams();
|
||||
}
|
||||
@@ -229,10 +231,11 @@ bool Transport::paramExists(const char *name, Method method /* = GET */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Transport::getParam(const char *name, Method method /* = GET */) {
|
||||
std::string Transport::getParam(const char *name,
|
||||
Method method /* = Method::GET */) {
|
||||
assert(name && *name);
|
||||
|
||||
if (method == GET || method == AUTO) {
|
||||
if (method == Method::GET || method == Method::AUTO) {
|
||||
if (m_url == nullptr) {
|
||||
parseGetParams();
|
||||
}
|
||||
@@ -242,7 +245,7 @@ std::string Transport::getParam(const char *name, Method method /* = GET */) {
|
||||
}
|
||||
}
|
||||
|
||||
if (method == POST || method == AUTO) {
|
||||
if (method == Method::POST || method == Method::AUTO) {
|
||||
if (!m_postDataParsed) {
|
||||
parsePostParams();
|
||||
}
|
||||
@@ -255,7 +258,8 @@ std::string Transport::getParam(const char *name, Method method /* = GET */) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int Transport::getIntParam(const char *name, Method method /* = GET */) {
|
||||
int Transport::getIntParam(const char *name,
|
||||
Method method /* = Method::GET */) {
|
||||
std::string param = getParam(name, method);
|
||||
if (param.empty()) {
|
||||
return 0;
|
||||
@@ -264,7 +268,7 @@ int Transport::getIntParam(const char *name, Method method /* = GET */) {
|
||||
}
|
||||
|
||||
long long Transport::getInt64Param(const char *name,
|
||||
Method method /* = GET */) {
|
||||
Method method /* = Method::GET */) {
|
||||
std::string param = getParam(name, method);
|
||||
if (param.empty()) {
|
||||
return 0;
|
||||
@@ -275,7 +279,7 @@ long long Transport::getInt64Param(const char *name,
|
||||
void Transport::getArrayParam(const char *name,
|
||||
std::vector<std::string> &values,
|
||||
Method method /* = GET */) {
|
||||
if (method == GET || method == AUTO) {
|
||||
if (method == Method::GET || method == Method::AUTO) {
|
||||
if (m_url == nullptr) {
|
||||
parseGetParams();
|
||||
}
|
||||
@@ -286,7 +290,7 @@ void Transport::getArrayParam(const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
if (method == POST || method == AUTO) {
|
||||
if (method == Method::POST || method == Method::AUTO) {
|
||||
if (!m_postDataParsed) {
|
||||
parsePostParams();
|
||||
}
|
||||
@@ -300,7 +304,8 @@ void Transport::getArrayParam(const char *name,
|
||||
|
||||
void Transport::getSplitParam(const char *name,
|
||||
std::vector<std::string> &values,
|
||||
char delimiter, Method method /* = GET */) {
|
||||
char delimiter,
|
||||
Method method /* = Method::GET */) {
|
||||
std::string param = getParam(name, method);
|
||||
if (!param.empty()) {
|
||||
Util::split(delimiter, param.c_str(), values);
|
||||
@@ -363,7 +368,7 @@ void Transport::addHeaderNoLock(const char *name, const char *value) {
|
||||
/* Zend seems to set 303 on a post with HTTP version > 1.0 in the code but
|
||||
* in our testing we can only get it to give 302.
|
||||
Method m = getMethod();
|
||||
if (m != GET && m != HEAD) {
|
||||
if (m != Method::GET && m != Method::HEAD) {
|
||||
setResponse(303);
|
||||
} else {
|
||||
setResponse(302);
|
||||
@@ -472,11 +477,11 @@ string Transport::getCookie(const string &name) {
|
||||
}
|
||||
|
||||
bool Transport::decideCompression() {
|
||||
assert(m_compressionDecision == NotDecidedYet);
|
||||
assert(m_compressionDecision == CompressionDecision::NotDecidedYet);
|
||||
|
||||
if (!RuntimeOption::ForceCompressionURL.empty() &&
|
||||
getCommand() == RuntimeOption::ForceCompressionURL) {
|
||||
m_compressionDecision = HasToCompress;
|
||||
m_compressionDecision = CompressionDecision::HasTo;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -485,11 +490,11 @@ bool Transport::decideCompression() {
|
||||
cookieExists(RuntimeOption::ForceCompressionCookie.c_str())) ||
|
||||
(!RuntimeOption::ForceCompressionParam.empty() &&
|
||||
paramExists(RuntimeOption::ForceCompressionParam.c_str()))) {
|
||||
m_compressionDecision = ShouldCompress;
|
||||
m_compressionDecision = CompressionDecision::Should;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_compressionDecision = ShouldNotCompress;
|
||||
m_compressionDecision = CompressionDecision::ShouldNot;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -551,8 +556,7 @@ bool Transport::setCookie(CStrRef name, CStrRef value, int64_t expire /* = 0 */,
|
||||
* so in order to force cookies to be deleted, even on MSIE, we
|
||||
* pick an expiry date in the past
|
||||
*/
|
||||
String sdt = DateTime(1, true)
|
||||
.toString(DateTime::Cookie);
|
||||
String sdt = DateTime(1, true).toString(DateTime::DateFormat::Cookie);
|
||||
cookie += name.data();
|
||||
cookie += "=deleted; expires=";
|
||||
cookie += sdt.data();
|
||||
@@ -566,7 +570,8 @@ bool Transport::setCookie(CStrRef name, CStrRef value, int64_t expire /* = 0 */,
|
||||
return false;
|
||||
}
|
||||
cookie += "; expires=";
|
||||
String sdt = DateTime(expire, true).toString(DateTime::Cookie);
|
||||
String sdt =
|
||||
DateTime(expire, true).toString(DateTime::DateFormat::Cookie);
|
||||
cookie += sdt.data();
|
||||
}
|
||||
}
|
||||
@@ -687,11 +692,11 @@ String Transport::prepareResponse(const void *data, int size, bool &compressed,
|
||||
// we don't use chunk encoding to send anything pre-compressed
|
||||
assert(!compressed || !m_chunkedEncoding);
|
||||
|
||||
if (m_compressionDecision == NotDecidedYet) {
|
||||
if (m_compressionDecision == CompressionDecision::NotDecidedYet) {
|
||||
decideCompression();
|
||||
}
|
||||
if (compressed || !isCompressionEnabled() ||
|
||||
m_compressionDecision == ShouldNotCompress) {
|
||||
m_compressionDecision == CompressionDecision::ShouldNot) {
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -699,7 +704,7 @@ String Transport::prepareResponse(const void *data, int size, bool &compressed,
|
||||
// Ethernet packet (1500 bytes), unless we are doing chunked encoding,
|
||||
// where we don't really know if next chunk will benefit from compresseion.
|
||||
if (m_chunkedEncoding || size > 1000 ||
|
||||
m_compressionDecision == HasToCompress) {
|
||||
m_compressionDecision == CompressionDecision::HasTo) {
|
||||
if (m_compressor == nullptr) {
|
||||
m_compressor = new StreamCompressor(RuntimeOption::GzipCompressionLevel,
|
||||
CODING_GZIP, true);
|
||||
@@ -710,7 +715,7 @@ String Transport::prepareResponse(const void *data, int size, bool &compressed,
|
||||
if (compressedData) {
|
||||
String deleter(compressedData, len, AttachString);
|
||||
if (m_chunkedEncoding || len < size ||
|
||||
m_compressionDecision == HasToCompress) {
|
||||
m_compressionDecision == CompressionDecision::HasTo) {
|
||||
response = deleter;
|
||||
compressed = true;
|
||||
}
|
||||
@@ -781,9 +786,9 @@ void Transport::sendRawLocked(void *data, int size, int code /* = 200 */,
|
||||
}
|
||||
|
||||
m_responseSize += response.size();
|
||||
ServerStats::SetThreadMode(ServerStats::Writing);
|
||||
ServerStats::SetThreadMode(ServerStats::ThreadMode::Writing);
|
||||
sendImpl(response.data(), response.size(), m_responseCode, chunked);
|
||||
ServerStats::SetThreadMode(ServerStats::Processing);
|
||||
ServerStats::SetThreadMode(ServerStats::ThreadMode::Processing);
|
||||
|
||||
ServerStats::LogBytes(size);
|
||||
if (RuntimeOption::EnableStats && RuntimeOption::EnableWebStats) {
|
||||
@@ -873,10 +878,10 @@ bool Transport::moveUploadedFile(CStrRef filename, CStrRef destination) {
|
||||
|
||||
const char *Transport::getThreadTypeName() const {
|
||||
switch (m_threadType) {
|
||||
case RequestThread: return "Web Request";
|
||||
case PageletThread: return "Pagelet Thread";
|
||||
case XboxThread: return "Xbox Thread";
|
||||
case RpcThread: return "RPC Thread";
|
||||
case ThreadType::RequestThread: return "Web Request";
|
||||
case ThreadType::PageletThread: return "Pagelet Thread";
|
||||
case ThreadType::XboxThread: return "Xbox Thread";
|
||||
case ThreadType::RpcThread: return "RPC Thread";
|
||||
}
|
||||
return "(unknown)";
|
||||
}
|
||||
@@ -886,7 +891,7 @@ void Transport::debuggerInfo(InfoVec &info) {
|
||||
Add(info, "URL", getCommand());
|
||||
Add(info, "HTTP", getHTTPVersion());
|
||||
Add(info, "Method", getMethodName());
|
||||
if (getMethod() == Transport::POST) {
|
||||
if (getMethod() == Method::POST) {
|
||||
int size; getPostData(size);
|
||||
Add(info, "Post Data", FormatSize(size));
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ typedef std::map<std::string, std::string, stdltistr> CookieMap;
|
||||
*/
|
||||
class Transport : public IDebuggable {
|
||||
public:
|
||||
enum Method {
|
||||
UnknownMethod,
|
||||
enum class Method {
|
||||
Unknown,
|
||||
|
||||
GET,
|
||||
POST,
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
|
||||
// TODO: add all status codes
|
||||
// (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
|
||||
enum StatusCode {
|
||||
UnknownStatusCode,
|
||||
enum class StatusCode {
|
||||
Unknown,
|
||||
|
||||
// Success
|
||||
OK = 200,
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
SERVICE_UNAVAILABLE = 503,
|
||||
};
|
||||
|
||||
enum ThreadType {
|
||||
enum class ThreadType {
|
||||
RequestThread,
|
||||
PageletThread,
|
||||
XboxThread,
|
||||
@@ -230,22 +230,22 @@ public:
|
||||
* Whether a parameter exists. Normally this is not needed to know, unless
|
||||
* "null" is different from an empty string or 0.
|
||||
*/
|
||||
bool paramExists(const char *name, Method method = GET);
|
||||
bool paramExists(const char *name, Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Get value of a parameter. Returns empty string is not present.
|
||||
*/
|
||||
std::string getParam(const char *name, Method method = GET);
|
||||
std::string getParam(const char *name, Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Turn a string parameter into an integer.
|
||||
*/
|
||||
int getIntParam(const char *name, Method method = GET);
|
||||
int getIntParam(const char *name, Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Turn a string parameter into a 64-bit number.
|
||||
*/
|
||||
long long getInt64Param(const char *name, Method method = GET);
|
||||
long long getInt64Param(const char *name, Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Collect multiple string parameters with the same name into "values".
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
* /foo?x=1&x=2&x=3
|
||||
*/
|
||||
void getArrayParam(const char *name, std::vector<std::string> &values,
|
||||
Method method = GET);
|
||||
Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Split a string parameter into multiple sub-strings.
|
||||
@@ -261,7 +261,7 @@ public:
|
||||
* /foo?x=1:2:3
|
||||
*/
|
||||
void getSplitParam(const char *name, std::vector<std::string> &values,
|
||||
char delimiter, Method method = GET);
|
||||
char delimiter, Method method = Method::GET);
|
||||
|
||||
/**
|
||||
* Test whether client accepts a certain encoding.
|
||||
@@ -400,11 +400,11 @@ protected:
|
||||
|
||||
bool m_isSSL;
|
||||
|
||||
enum CompressionDecision {
|
||||
enum class CompressionDecision {
|
||||
NotDecidedYet,
|
||||
ShouldNotCompress,
|
||||
ShouldCompress,
|
||||
HasToCompress,
|
||||
ShouldNot,
|
||||
Should,
|
||||
HasTo,
|
||||
};
|
||||
CompressionDecision m_compressionDecision;
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#include "hphp/runtime/base/comparisons.h"
|
||||
#include "hphp/runtime/base/server/virtual_host.h"
|
||||
#include "hphp/runtime/base/comparisons.h"
|
||||
#include "hphp/runtime/base/preg.h"
|
||||
#include "hphp/runtime/base/runtime_option.h"
|
||||
#include "hphp/runtime/base/comparisons.h"
|
||||
@@ -203,15 +203,15 @@ void VirtualHost::init(Hdf vh) {
|
||||
const char *type = chdf["type"].get();
|
||||
if (type) {
|
||||
if (strcasecmp(type, "host") == 0) {
|
||||
cond.type = RewriteCond::Host;
|
||||
cond.type = RewriteCond::Type::Host;
|
||||
} else if (strcasecmp(type, "request") == 0) {
|
||||
cond.type = RewriteCond::Request;
|
||||
cond.type = RewriteCond::Type::Request;
|
||||
} else {
|
||||
throw InvalidArgumentException("rewrite rule",
|
||||
"(invalid cond type)");
|
||||
}
|
||||
} else {
|
||||
cond.type = RewriteCond::Request;
|
||||
cond.type = RewriteCond::Type::Request;
|
||||
}
|
||||
cond.negate = chdf["negate"].getBool(false);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ bool VirtualHost::rewriteURL(CStrRef host, String &url, bool &qsa,
|
||||
for (vector<RewriteCond>::const_iterator it = rule.rewriteConds.begin();
|
||||
it != rule.rewriteConds.end(); ++it) {
|
||||
String subject;
|
||||
if (it->type == RewriteCond::Request) {
|
||||
if (it->type == RewriteCond::Type::Request) {
|
||||
subject = normalized;
|
||||
} else {
|
||||
subject = host;
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
static void SortAllowedDirectories(std::vector<std::string>& dirs);
|
||||
public:
|
||||
VirtualHost();
|
||||
VirtualHost(Hdf vh);
|
||||
explicit VirtualHost(Hdf vh);
|
||||
|
||||
void init(Hdf vh);
|
||||
void addAllowedDirectories(const std::vector<std::string>& dirs);
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
struct RewriteCond {
|
||||
enum Type {
|
||||
enum class Type {
|
||||
Request,
|
||||
Host
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
return m_message.data();
|
||||
}
|
||||
virtual Method getMethod() {
|
||||
return Transport::POST;
|
||||
return Transport::Method::POST;
|
||||
}
|
||||
virtual std::string getHeader(const char *name) {
|
||||
if (!strcasecmp(name, "Host")) return m_host;
|
||||
@@ -182,7 +182,8 @@ private:
|
||||
}
|
||||
if (RuntimeOption::XboxServerLogInfo) XboxRequestHandler::Info = true;
|
||||
s_xbox_request_handler->setServerInfo(*s_xbox_server_info);
|
||||
s_xbox_request_handler->setReturnEncodeType(RPCRequestHandler::Serialize);
|
||||
s_xbox_request_handler->setReturnEncodeType(
|
||||
RPCRequestHandler::ReturnEncodeType::Serialize);
|
||||
return s_xbox_request_handler.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
class XboxServerInfo : public SatelliteServerInfo {
|
||||
public:
|
||||
XboxServerInfo() : SatelliteServerInfo(Hdf()) {
|
||||
m_type = SatelliteServer::KindOfXboxServer;
|
||||
m_type = SatelliteServer::Type::KindOfXboxServer;
|
||||
m_name = "xbox";
|
||||
reload();
|
||||
}
|
||||
|
||||
@@ -246,8 +246,8 @@ SharedVariant* ConcurrentTableSharedStore::unserialize(CStrRef key,
|
||||
try {
|
||||
VariableUnserializer::Type sType =
|
||||
RuntimeOption::EnableApcSerialize ?
|
||||
VariableUnserializer::APCSerialize :
|
||||
VariableUnserializer::Serialize;
|
||||
VariableUnserializer::Type::APCSerialize :
|
||||
VariableUnserializer::Type::Serialize;
|
||||
|
||||
VariableUnserializer vu(sval->sAddr, sval->getSerializedSize(), sType);
|
||||
Variant v;
|
||||
@@ -502,7 +502,8 @@ void ConcurrentTableSharedStore::prime
|
||||
|
||||
bool ConcurrentTableSharedStore::constructPrime(CStrRef v, KeyValuePair& item,
|
||||
bool serialized) {
|
||||
if (s_apc_file_storage.getState() != SharedStoreFileStorage::StateInvalid &&
|
||||
if (s_apc_file_storage.getState() !=
|
||||
SharedStoreFileStorage::StorageState::Invalid &&
|
||||
(!v->isStatic() || serialized)) {
|
||||
// StaticString for non-object should consume limited amount of space,
|
||||
// not worth going through the file storage
|
||||
@@ -524,7 +525,8 @@ bool ConcurrentTableSharedStore::constructPrime(CStrRef v, KeyValuePair& item,
|
||||
|
||||
bool ConcurrentTableSharedStore::constructPrime(CVarRef v,
|
||||
KeyValuePair& item) {
|
||||
if (s_apc_file_storage.getState() != SharedStoreFileStorage::StateInvalid &&
|
||||
if (s_apc_file_storage.getState() !=
|
||||
SharedStoreFileStorage::StorageState::Invalid &&
|
||||
(IS_REFCOUNTED_TYPE(v.getType()))) {
|
||||
// Only do the storage for ref-counted type
|
||||
String s = apc_serialize(v);
|
||||
@@ -540,7 +542,8 @@ bool ConcurrentTableSharedStore::constructPrime(CVarRef v,
|
||||
}
|
||||
|
||||
void ConcurrentTableSharedStore::primeDone() {
|
||||
if (s_apc_file_storage.getState() != SharedStoreFileStorage::StateInvalid) {
|
||||
if (s_apc_file_storage.getState() !=
|
||||
SharedStoreFileStorage::StorageState::Invalid) {
|
||||
s_apc_file_storage.seal();
|
||||
s_apc_file_storage.hashCheck();
|
||||
// Schedule the adviseOut instead of doing it immediately, so that the
|
||||
@@ -589,7 +592,7 @@ void ConcurrentTableSharedStore::dump(std::ostream & out, bool keyOnly,
|
||||
out << " #### ";
|
||||
const StoreValue *sval = &iter->second;
|
||||
if (!sval->expired()) {
|
||||
VariableSerializer vs(VariableSerializer::Serialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::Serialize);
|
||||
Variant value;
|
||||
if (sval->inMem()) {
|
||||
value = sval->var->toLocal();
|
||||
|
||||
@@ -85,7 +85,7 @@ SharedStores::SharedStores() {
|
||||
void SharedStores::create() {
|
||||
for (int i = 0; i < MAX_SHARED_STORE; i++) {
|
||||
switch (RuntimeOption::ApcTableType) {
|
||||
case RuntimeOption::ApcConcurrentTable:
|
||||
case RuntimeOption::ApcTableTypes::ApcConcurrentTable:
|
||||
m_stores[i] = new ConcurrentTableSharedStore(i);
|
||||
break;
|
||||
default:
|
||||
@@ -124,24 +124,24 @@ void SharedStoreFileStorage::enable(const std::string& prefix,
|
||||
m_prefix = prefix;
|
||||
m_chunkSize = chunkSize;
|
||||
m_maxSize = maxSize;
|
||||
if (m_state != StateInvalid) {
|
||||
if (m_state != StorageState::Invalid) {
|
||||
return;
|
||||
}
|
||||
if (!addFile()) {
|
||||
Logger::Error("Failed to open file for apc, fallback to in-memory mode");
|
||||
return;
|
||||
}
|
||||
m_state = StateOpen;
|
||||
m_state = StorageState::Open;
|
||||
}
|
||||
|
||||
char *SharedStoreFileStorage::put(const char *data, int32_t len) {
|
||||
Lock lock(m_lock);
|
||||
if (m_state != StateOpen ||
|
||||
if (m_state != StorageState::Open ||
|
||||
len + PaddingSize > m_chunkSize - PaddingSize) {
|
||||
return nullptr;
|
||||
}
|
||||
if (len + PaddingSize > m_chunkRemain && !addFile()) {
|
||||
m_state = StateFull;
|
||||
m_state = StorageState::Full;
|
||||
return nullptr;
|
||||
}
|
||||
assert(m_current);
|
||||
@@ -163,13 +163,13 @@ char *SharedStoreFileStorage::put(const char *data, int32_t len) {
|
||||
|
||||
void SharedStoreFileStorage::seal() {
|
||||
Lock lock(m_lock);
|
||||
if (m_state == StateSealed) {
|
||||
if (m_state == StorageState::Sealed) {
|
||||
return;
|
||||
}
|
||||
assert(m_state == StateOpen || m_state == StateFull);
|
||||
assert(m_state == StorageState::Open || m_state == StorageState::Full);
|
||||
m_current = nullptr;
|
||||
m_chunkRemain = 0;
|
||||
m_state = StateSealed;
|
||||
m_state = StorageState::Sealed;
|
||||
|
||||
for (int i = 0; i < (int)m_chunks.size(); i++) {
|
||||
if (mprotect(m_chunks[i], m_chunkSize, PROT_READ) < 0) {
|
||||
@@ -235,7 +235,7 @@ void SharedStoreFileStorage::cleanup() {
|
||||
|
||||
bool SharedStoreFileStorage::addFile() {
|
||||
if ((int64_t)m_chunks.size() * m_chunkSize >= m_maxSize) {
|
||||
m_state = StateFull;
|
||||
m_state = StorageState::Full;
|
||||
return false;
|
||||
}
|
||||
char name[PATH_MAX];
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
class SharedStore {
|
||||
public:
|
||||
SharedStore(int id);
|
||||
explicit SharedStore(int id);
|
||||
virtual ~SharedStore();
|
||||
|
||||
virtual bool clear() = 0;
|
||||
@@ -150,15 +150,15 @@ extern SharedStores s_apc_store;
|
||||
|
||||
class SharedStoreFileStorage {
|
||||
public:
|
||||
enum StorageState {
|
||||
StateInvalid,
|
||||
StateOpen,
|
||||
StateSealed,
|
||||
StateFull
|
||||
enum class StorageState {
|
||||
Invalid,
|
||||
Open,
|
||||
Sealed,
|
||||
Full
|
||||
};
|
||||
|
||||
SharedStoreFileStorage()
|
||||
: m_state(StateInvalid), m_current(nullptr), m_chunkRemain(0) {}
|
||||
: m_state(StorageState::Invalid), m_current(nullptr), m_chunkRemain(0) {}
|
||||
void enable(const std::string& prefix, int64_t chunkSize, int64_t maxSize);
|
||||
char *put(const char *data, int32_t len);
|
||||
void seal();
|
||||
|
||||
@@ -641,8 +641,8 @@ void StringData::setChar(int offset, char ch) {
|
||||
*/
|
||||
char *increment_string(char *s, uint32_t &len) {
|
||||
assert(s && *s);
|
||||
enum CharKind {
|
||||
UNKNOWN_KIND,
|
||||
enum class CharKind {
|
||||
UNKNOWN,
|
||||
LOWER_CASE,
|
||||
UPPER_CASE,
|
||||
NUMERIC
|
||||
@@ -650,7 +650,7 @@ char *increment_string(char *s, uint32_t &len) {
|
||||
|
||||
int carry = 0;
|
||||
int pos = len - 1;
|
||||
int last = UNKNOWN_KIND; // Shut up the compiler warning
|
||||
CharKind last = CharKind::UNKNOWN; // Shut up the compiler warning
|
||||
int ch;
|
||||
|
||||
while (pos >= 0) {
|
||||
@@ -663,7 +663,7 @@ char *increment_string(char *s, uint32_t &len) {
|
||||
s[pos]++;
|
||||
carry=0;
|
||||
}
|
||||
last=LOWER_CASE;
|
||||
last = CharKind::LOWER_CASE;
|
||||
} else if (ch >= 'A' && ch <= 'Z') {
|
||||
if (ch == 'Z') {
|
||||
s[pos] = 'A';
|
||||
@@ -672,7 +672,7 @@ char *increment_string(char *s, uint32_t &len) {
|
||||
s[pos]++;
|
||||
carry=0;
|
||||
}
|
||||
last=UPPER_CASE;
|
||||
last = CharKind::UPPER_CASE;
|
||||
} else if (ch >= '0' && ch <= '9') {
|
||||
if (ch == '9') {
|
||||
s[pos] = '0';
|
||||
@@ -681,7 +681,7 @@ char *increment_string(char *s, uint32_t &len) {
|
||||
s[pos]++;
|
||||
carry=0;
|
||||
}
|
||||
last = NUMERIC;
|
||||
last = CharKind::NUMERIC;
|
||||
} else {
|
||||
carry=0;
|
||||
break;
|
||||
@@ -697,15 +697,17 @@ char *increment_string(char *s, uint32_t &len) {
|
||||
memcpy(t+1, s, len);
|
||||
t[++len] = '\0';
|
||||
switch (last) {
|
||||
case NUMERIC:
|
||||
case CharKind::NUMERIC:
|
||||
t[0] = '1';
|
||||
break;
|
||||
case UPPER_CASE:
|
||||
case CharKind::UPPER_CASE:
|
||||
t[0] = 'A';
|
||||
break;
|
||||
case LOWER_CASE:
|
||||
case CharKind::LOWER_CASE:
|
||||
t[0] = 'a';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -26,19 +26,20 @@ namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// manipulations
|
||||
|
||||
String StringUtil::ToLower(CStrRef input, ToLowerType type /*= ToLowerAll */) {
|
||||
String StringUtil::ToLower(CStrRef input,
|
||||
ToLowerType type /*= ToLowerType::All */) {
|
||||
if (input.empty()) return input;
|
||||
|
||||
int len = input.size();
|
||||
char *ret = nullptr;
|
||||
switch (type) {
|
||||
case ToLowerAll:
|
||||
case ToLowerType::All:
|
||||
ret = string_to_lower(input.data(), len);
|
||||
break;
|
||||
case ToLowerFirst:
|
||||
case ToLowerType::First:
|
||||
ret = string_to_lower_first(input.data(), len);
|
||||
break;
|
||||
case ToLowerWords:
|
||||
case ToLowerType::Words:
|
||||
ret = string_to_lower_words(input.data(), len);
|
||||
break;
|
||||
default:
|
||||
@@ -48,19 +49,20 @@ String StringUtil::ToLower(CStrRef input, ToLowerType type /*= ToLowerAll */) {
|
||||
return String(ret, len, AttachString);
|
||||
}
|
||||
|
||||
String StringUtil::ToUpper(CStrRef input, ToUpperType type /*= ToUpperAll */) {
|
||||
String StringUtil::ToUpper(CStrRef input,
|
||||
ToUpperType type /*= ToUpperType::All */) {
|
||||
if (input.empty()) return input;
|
||||
|
||||
int len = input.size();
|
||||
char *ret = nullptr;
|
||||
switch (type) {
|
||||
case ToUpperAll:
|
||||
case ToUpperType::All:
|
||||
ret = string_to_upper(input.data(), len);
|
||||
break;
|
||||
case ToUpperFirst:
|
||||
case ToUpperType::First:
|
||||
ret = string_to_upper_first(input.data(), len);
|
||||
break;
|
||||
case ToUpperWords:
|
||||
case ToUpperType::Words:
|
||||
ret = string_to_upper_words(input.data(), len);
|
||||
break;
|
||||
default:
|
||||
@@ -70,12 +72,13 @@ String StringUtil::ToUpper(CStrRef input, ToUpperType type /*= ToUpperAll */) {
|
||||
return String(ret, len, AttachString);
|
||||
}
|
||||
|
||||
String StringUtil::Trim(CStrRef input, TrimType type /* = TrimBoth */,
|
||||
String StringUtil::Trim(CStrRef input, TrimType type /* = TrimType::Both */,
|
||||
CStrRef charlist /* = k_HPHP_TRIM_CHARLIST */) {
|
||||
if (input.empty()) return input;
|
||||
int len = input.size();
|
||||
char *ret = string_trim(input.data(), len,
|
||||
charlist.data(), charlist.length(), type);
|
||||
charlist.data(), charlist.length(),
|
||||
static_cast<int>(type));
|
||||
if (!ret) {
|
||||
return input;
|
||||
}
|
||||
@@ -84,10 +87,10 @@ String StringUtil::Trim(CStrRef input, TrimType type /* = TrimBoth */,
|
||||
|
||||
String StringUtil::Pad(CStrRef input, int final_length,
|
||||
CStrRef pad_string /* = " " */,
|
||||
PadType type /* = PadRight */) {
|
||||
PadType type /* = PadType::Right */) {
|
||||
int len = input.size();
|
||||
char *ret = string_pad(input.data(), len, final_length, pad_string.data(),
|
||||
pad_string.size(), type);
|
||||
pad_string.size(), static_cast<int>(type));
|
||||
if (ret) return String(ret, len, AttachString);
|
||||
return String();
|
||||
}
|
||||
@@ -351,8 +354,10 @@ String StringUtil::HtmlEncode(CStrRef input, QuoteStyle quoteStyle,
|
||||
}
|
||||
|
||||
int len = input.size();
|
||||
char *ret = string_html_encode(input.data(), len, quoteStyle != NoQuotes,
|
||||
quoteStyle == BothQuotes, utf8, nbsp);
|
||||
char *ret = string_html_encode(input.data(), len,
|
||||
quoteStyle != QuoteStyle::No,
|
||||
quoteStyle == QuoteStyle::Both,
|
||||
utf8, nbsp);
|
||||
if (!ret) {
|
||||
raise_error("HtmlEncode called on too large input (%d)", len);
|
||||
}
|
||||
@@ -403,21 +408,21 @@ String StringUtil::HtmlEncodeExtra(CStrRef input, QuoteStyle quoteStyle,
|
||||
AsciiMap tmp;
|
||||
|
||||
switch (quoteStyle) {
|
||||
case FBUtf8Only:
|
||||
case QuoteStyle::FBUtf8Only:
|
||||
am = &mapNothing;
|
||||
flags |= STRING_HTML_ENCODE_HIGH;
|
||||
break;
|
||||
case FBUtf8:
|
||||
case QuoteStyle::FBUtf8:
|
||||
am = &mapBothQuotes;
|
||||
flags |= STRING_HTML_ENCODE_HIGH;
|
||||
break;
|
||||
case BothQuotes:
|
||||
case QuoteStyle::Both:
|
||||
am = &mapBothQuotes;
|
||||
break;
|
||||
case DoubleQuotes:
|
||||
case QuoteStyle::Double:
|
||||
am = &mapDoubleQuotes;
|
||||
break;
|
||||
case NoQuotes:
|
||||
case QuoteStyle::No:
|
||||
am = &mapNoQuotes;
|
||||
break;
|
||||
default:
|
||||
@@ -425,7 +430,7 @@ String StringUtil::HtmlEncodeExtra(CStrRef input, QuoteStyle quoteStyle,
|
||||
raise_error("Unknown quote style: %d", (int)quoteStyle);
|
||||
}
|
||||
|
||||
if (quoteStyle != FBUtf8Only && extra.toBoolean()) {
|
||||
if (quoteStyle != QuoteStyle::FBUtf8Only && extra.toBoolean()) {
|
||||
tmp = *am;
|
||||
am = &tmp;
|
||||
for (ArrayIter iter(extra); iter; ++iter) {
|
||||
@@ -451,8 +456,10 @@ String StringUtil::HtmlDecode(CStrRef input, QuoteStyle quoteStyle,
|
||||
assert(charset);
|
||||
|
||||
int len = input.size();
|
||||
char *ret = string_html_decode(input.data(), len, quoteStyle != NoQuotes,
|
||||
quoteStyle == BothQuotes, charset, all);
|
||||
char *ret = string_html_decode(input.data(), len,
|
||||
quoteStyle != QuoteStyle::No,
|
||||
quoteStyle == QuoteStyle::Both,
|
||||
charset, all);
|
||||
if (!ret) {
|
||||
// null iff charset was not recognized
|
||||
throw NotImplementedException(charset);
|
||||
|
||||
@@ -30,34 +30,34 @@ extern const StaticString k_HPHP_TRIM_CHARLIST;
|
||||
*/
|
||||
class StringUtil {
|
||||
public:
|
||||
enum ToUpperType {
|
||||
ToUpperAll,
|
||||
ToUpperFirst,
|
||||
ToUpperWords
|
||||
enum class ToUpperType {
|
||||
All,
|
||||
First,
|
||||
Words
|
||||
};
|
||||
|
||||
enum ToLowerType {
|
||||
ToLowerAll,
|
||||
ToLowerFirst,
|
||||
ToLowerWords
|
||||
enum class ToLowerType {
|
||||
All,
|
||||
First,
|
||||
Words
|
||||
};
|
||||
|
||||
enum TrimType {
|
||||
TrimLeft = 1,
|
||||
TrimRight = 2,
|
||||
TrimBoth = 3
|
||||
enum class TrimType {
|
||||
Left = 1,
|
||||
Right = 2,
|
||||
Both = 3
|
||||
};
|
||||
|
||||
enum PadType {
|
||||
PadLeft = 0,
|
||||
PadRight = 1,
|
||||
PadBoth = 2
|
||||
enum class PadType {
|
||||
Left = 0,
|
||||
Right = 1,
|
||||
Both = 2
|
||||
};
|
||||
|
||||
enum QuoteStyle {
|
||||
DoubleQuotes = 2, // k_ENT_COMPAT: escape double quotes only
|
||||
BothQuotes = 3, // k_ENT_QUOTES: escape both double and single quotes
|
||||
NoQuotes = 0, // k_ENT_NOQUOTES: leave all quotes alone
|
||||
enum class QuoteStyle {
|
||||
Double = 2, // k_ENT_COMPAT: escape double quotes only
|
||||
Both = 3, // k_ENT_QUOTES: escape both double and single quotes
|
||||
No = 0, // k_ENT_NOQUOTES: leave all quotes alone
|
||||
FBUtf8 = 4,
|
||||
FBUtf8Only = 8
|
||||
};
|
||||
@@ -67,12 +67,12 @@ public:
|
||||
* Manipulations. Note, all these functions will create a new string than
|
||||
* modifying input, although names of these functions sound like mutating.
|
||||
*/
|
||||
static String ToLower(CStrRef input, ToLowerType type = ToLowerAll);
|
||||
static String ToUpper(CStrRef input, ToUpperType type = ToUpperAll);
|
||||
static String Trim(CStrRef input, TrimType type = TrimBoth,
|
||||
static String ToLower(CStrRef input, ToLowerType type = ToLowerType::All);
|
||||
static String ToUpper(CStrRef input, ToUpperType type = ToUpperType::All);
|
||||
static String Trim(CStrRef input, TrimType type = TrimType::Both,
|
||||
CStrRef charlist = k_HPHP_TRIM_CHARLIST);
|
||||
static String Pad(CStrRef input, int final_length,
|
||||
CStrRef pad_string = " ", PadType type = PadRight);
|
||||
CStrRef pad_string = " ", PadType type = PadType::Right);
|
||||
static String Reverse(CStrRef input);
|
||||
static String Repeat(CStrRef input, int count);
|
||||
static String Shuffle(CStrRef input);
|
||||
|
||||
@@ -38,9 +38,9 @@ InitFiniNode *extra_init, *extra_fini, *extra_process_init, *extra_process_exit;
|
||||
|
||||
InitFiniNode::InitFiniNode(void(*f)(), When init) {
|
||||
InitFiniNode *&ifn =
|
||||
init == ThreadInit ? extra_init :
|
||||
init == ThreadFini ? extra_fini :
|
||||
init == ProcessInit ? extra_process_init : extra_process_exit;
|
||||
init == When::ThreadInit ? extra_init :
|
||||
init == When::ThreadFini ? extra_fini :
|
||||
init == When::ProcessInit ? extra_process_init : extra_process_exit;
|
||||
|
||||
func = f;
|
||||
next = ifn;
|
||||
|
||||
@@ -28,7 +28,7 @@ void finish_thread_locals(void *arg = nullptr) ATTRIBUTE_COLD
|
||||
NEVER_INLINE;
|
||||
|
||||
struct InitFiniNode {
|
||||
enum When {
|
||||
enum class When {
|
||||
ThreadInit,
|
||||
ThreadFini,
|
||||
ProcessInit,
|
||||
|
||||
@@ -532,15 +532,15 @@ String DateTime::toString(CStrRef format, bool stdc /* = false */) const {
|
||||
|
||||
String DateTime::toString(DateFormat format) const {
|
||||
switch (format) {
|
||||
case RFC822: return rfcFormat(DateFormatRFC822);
|
||||
case RFC850: return rfcFormat(DateFormatRFC850);
|
||||
case RFC1036: return rfcFormat(DateFormatRFC1036);
|
||||
case RFC1123: return rfcFormat(DateFormatRFC1123);
|
||||
case RFC2822: return rfcFormat(DateFormatRFC2822);
|
||||
case RFC3339: return rfcFormat(DateFormatRFC3339);
|
||||
case ISO8601: return rfcFormat(DateFormatISO8601);
|
||||
case Cookie: return rfcFormat(DateFormatCookie);
|
||||
case HttpHeader: return rfcFormat(DateFormatHttpHeader);
|
||||
case DateFormat::RFC822: return rfcFormat(DateFormatRFC822);
|
||||
case DateFormat::RFC850: return rfcFormat(DateFormatRFC850);
|
||||
case DateFormat::RFC1036: return rfcFormat(DateFormatRFC1036);
|
||||
case DateFormat::RFC1123: return rfcFormat(DateFormatRFC1123);
|
||||
case DateFormat::RFC2822: return rfcFormat(DateFormatRFC2822);
|
||||
case DateFormat::RFC3339: return rfcFormat(DateFormatRFC3339);
|
||||
case DateFormat::ISO8601: return rfcFormat(DateFormatISO8601);
|
||||
case DateFormat::Cookie: return rfcFormat(DateFormatCookie);
|
||||
case DateFormat::HttpHeader: return rfcFormat(DateFormatHttpHeader);
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
@@ -686,7 +686,7 @@ Array DateTime::toArray(ArrayFormat format) const {
|
||||
Array ret;
|
||||
bool error;
|
||||
switch (format) {
|
||||
case TimeMap:
|
||||
case ArrayFormat::TimeMap:
|
||||
ret.set(s_seconds, second());
|
||||
ret.set(s_minutes, minute());
|
||||
ret.set(s_hours, hour());
|
||||
@@ -699,7 +699,7 @@ Array DateTime::toArray(ArrayFormat format) const {
|
||||
ret.set(s_month, monthName());
|
||||
ret.set(0, toTimeStamp(error));
|
||||
break;
|
||||
case TmMap:
|
||||
case ArrayFormat::TmMap:
|
||||
{
|
||||
struct tm tm;
|
||||
toTm(tm);
|
||||
@@ -714,7 +714,7 @@ Array DateTime::toArray(ArrayFormat format) const {
|
||||
ret.set(s_tm_isdst, tm.tm_isdst);
|
||||
}
|
||||
break;
|
||||
case TmVector:
|
||||
case ArrayFormat::TmVector:
|
||||
{
|
||||
struct tm tm;
|
||||
toTm(tm);
|
||||
@@ -903,9 +903,9 @@ Variant DateTime::getSunInfo(SunInfoFormat retformat,
|
||||
double latitude, double longitude,
|
||||
double zenith, double utc_offset,
|
||||
bool calc_sunset) const {
|
||||
if (retformat != ReturnTimeStamp &&
|
||||
retformat != ReturnString &&
|
||||
retformat != ReturnDouble) {
|
||||
if (retformat != SunInfoFormat::ReturnTimeStamp &&
|
||||
retformat != SunInfoFormat::ReturnString &&
|
||||
retformat != SunInfoFormat::ReturnDouble) {
|
||||
raise_warning("Wrong return format given, pick one of "
|
||||
"SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING or "
|
||||
"SUNFUNCS_RET_DOUBLE");
|
||||
@@ -930,7 +930,7 @@ Variant DateTime::getSunInfo(SunInfoFormat retformat,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (retformat == ReturnTimeStamp) {
|
||||
if (retformat == SunInfoFormat::ReturnTimeStamp) {
|
||||
return calc_sunset ? sunset : sunrise;
|
||||
}
|
||||
|
||||
@@ -939,14 +939,14 @@ Variant DateTime::getSunInfo(SunInfoFormat retformat,
|
||||
N -= floor(N / 24) * 24;
|
||||
}
|
||||
|
||||
if (retformat == ReturnString) {
|
||||
if (retformat == SunInfoFormat::ReturnString) {
|
||||
char retstr[6];
|
||||
snprintf(retstr, sizeof(retstr),
|
||||
"%02d:%02d", (int) N, (int) (60 * (N - (int) N)));
|
||||
return String(retstr, CopyString);
|
||||
}
|
||||
|
||||
assert(retformat == ReturnDouble);
|
||||
assert(retformat == SunInfoFormat::ReturnDouble);
|
||||
return N;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
/**
|
||||
* Different RFC/ISO date/time formats for toString(DateFormat).
|
||||
*/
|
||||
enum DateFormat {
|
||||
enum class DateFormat {
|
||||
InvalidFormat,
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
/**
|
||||
* Different array formats for toArray().
|
||||
*/
|
||||
enum ArrayFormat {
|
||||
enum class ArrayFormat {
|
||||
TimeMap,
|
||||
TmMap,
|
||||
TmVector
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
/**
|
||||
* Different formats for getSunInfo().
|
||||
*/
|
||||
enum SunInfoFormat {
|
||||
enum class SunInfoFormat {
|
||||
ReturnTimeStamp,
|
||||
ReturnString,
|
||||
ReturnDouble
|
||||
@@ -223,7 +223,7 @@ public:
|
||||
public:
|
||||
// constructor
|
||||
DateTime();
|
||||
DateTime(int64_t timestamp, bool utc = false); // from a timestamp
|
||||
explicit DateTime(int64_t timestamp, bool utc = false); // from a timestamp
|
||||
|
||||
static StaticString s_class_name;
|
||||
// overriding ResourceData
|
||||
|
||||
@@ -259,7 +259,7 @@ Array TimeZone::transitions() const {
|
||||
|
||||
ArrayInit element(5);
|
||||
element.set(s_ts, timestamp);
|
||||
element.set(s_time, dt.toString(DateTime::ISO8601));
|
||||
element.set(s_time, dt.toString(DateTime::DateFormat::ISO8601));
|
||||
element.set(s_offset, offset.offset);
|
||||
element.set(s_isdst, (bool)offset.isdst);
|
||||
element.set(s_abbr, String(abbr, CopyString));
|
||||
|
||||
@@ -833,7 +833,7 @@ void Array::unserialize(VariableUnserializer *uns) {
|
||||
// Pre-allocate an ArrayData of the given size, to avoid escalation in
|
||||
// the middle, which breaks references.
|
||||
operator=(ArrayInit(size).create());
|
||||
bool isAPC = (uns->getType() == VariableUnserializer::APCSerialize);
|
||||
bool isAPC = (uns->getType() == VariableUnserializer::Type::APCSerialize);
|
||||
for (int64_t i = 0; i < size; i++) {
|
||||
Variant key(uns->unserializeKey());
|
||||
if (!key.isString() && !key.isInteger()) {
|
||||
|
||||
@@ -2423,9 +2423,9 @@ void Variant::serialize(VariableSerializer *serializer,
|
||||
bool skipNestCheck /* = false */) const {
|
||||
if (m_type == KindOfRef) {
|
||||
// Ugly, but behavior is different for serialize
|
||||
if (serializer->getType() == VariableSerializer::Serialize ||
|
||||
serializer->getType() == VariableSerializer::APCSerialize ||
|
||||
serializer->getType() == VariableSerializer::DebuggerSerialize) {
|
||||
if (serializer->getType() == VariableSerializer::Type::Serialize ||
|
||||
serializer->getType() == VariableSerializer::Type::APCSerialize ||
|
||||
serializer->getType() == VariableSerializer::Type::DebuggerSerialize) {
|
||||
if (serializer->incNestedLevel(m_data.pref->var())) {
|
||||
serializer->writeOverflow(m_data.pref->var());
|
||||
} else {
|
||||
@@ -2492,7 +2492,7 @@ static void unserializeProp(VariableUnserializer *uns,
|
||||
}
|
||||
|
||||
void Variant::unserialize(VariableUnserializer *uns,
|
||||
Uns::Mode mode /* = Uns::ValueMode */) {
|
||||
Uns::Mode mode /* = Uns::Mode::Value */) {
|
||||
|
||||
char type, sep;
|
||||
type = uns->readChar();
|
||||
@@ -2571,7 +2571,7 @@ void Variant::unserialize(VariableUnserializer *uns,
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
if (uns->getType() == VariableUnserializer::APCSerialize) {
|
||||
if (uns->getType() == VariableUnserializer::Type::APCSerialize) {
|
||||
union {
|
||||
char buf[8];
|
||||
StringData *sd;
|
||||
@@ -2786,7 +2786,7 @@ Variant Variant::share(bool save) const {
|
||||
}
|
||||
|
||||
void Variant::dump() const {
|
||||
VariableSerializer vs(VariableSerializer::VarDump);
|
||||
VariableSerializer vs(VariableSerializer::Type::VarDump);
|
||||
String ret(vs.serialize(*this, true));
|
||||
printf("Variant: %s", ret.c_str());
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ class Variant : private TypedValue {
|
||||
bool isArrayKey = false,
|
||||
bool skipNestCheck = false) const;
|
||||
void unserialize(VariableUnserializer *unserializer,
|
||||
Uns::Mode mode = Uns::ValueMode);
|
||||
Uns::Mode mode = Uns::Mode::Value);
|
||||
|
||||
/**
|
||||
* Used by SharedStore to save/restore a variant.
|
||||
|
||||
@@ -123,11 +123,11 @@ class VariableUnserializer;
|
||||
*/
|
||||
|
||||
namespace Uns {
|
||||
enum Mode {
|
||||
ValueMode = 0,
|
||||
KeyMode = 1,
|
||||
ColValueMode = 2,
|
||||
ColKeyMode = 3,
|
||||
enum class Mode {
|
||||
Value = 0,
|
||||
Key = 1,
|
||||
ColValue = 2,
|
||||
ColKey = 3,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace HPHP {
|
||||
|
||||
class ExtendedException : public Exception {
|
||||
public:
|
||||
enum SkipFrame { skipFrame };
|
||||
enum class SkipFrame { skipFrame };
|
||||
ExtendedException();
|
||||
ExtendedException(const std::string &msg);
|
||||
explicit ExtendedException(const std::string &msg);
|
||||
ExtendedException(SkipFrame frame, const std::string &msg);
|
||||
ExtendedException(const char *fmt, ...);
|
||||
Array getBackTrace() const;
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
class InvalidObjectTypeException : public ExtendedException {
|
||||
public:
|
||||
InvalidObjectTypeException(const char *name)
|
||||
explicit InvalidObjectTypeException(const char *name)
|
||||
: ExtendedException("Unexpected object type %s.", name) {}
|
||||
virtual ~InvalidObjectTypeException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(InvalidObjectTypeException);
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
class InvalidOperandException : public ExtendedException {
|
||||
public:
|
||||
InvalidOperandException(const char *msg)
|
||||
explicit InvalidOperandException(const char *msg)
|
||||
: ExtendedException("Invalid operand type was used: %s.", msg) {}
|
||||
virtual ~InvalidOperandException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(InvalidOperandException);
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
class BadTypeConversionException : public ExtendedException {
|
||||
public:
|
||||
BadTypeConversionException(const char *msg)
|
||||
explicit BadTypeConversionException(const char *msg)
|
||||
: ExtendedException("Bad type conversion: %s.", msg) {}
|
||||
virtual ~BadTypeConversionException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(BadTypeConversionException);
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
|
||||
class InvalidFunctionCallException : public ExtendedException {
|
||||
public:
|
||||
InvalidFunctionCallException(const char *func)
|
||||
explicit InvalidFunctionCallException(const char *func)
|
||||
: ExtendedException("(1) call the function without enough arguments OR "
|
||||
"(2) Unable to find function \"%s\" OR "
|
||||
"(3) function was not in invoke table OR "
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
|
||||
class InvalidClassException : public ExtendedException {
|
||||
public:
|
||||
InvalidClassException(const char *cls)
|
||||
explicit InvalidClassException(const char *cls)
|
||||
: ExtendedException("Unable to find class \"%s\".", cls) {}
|
||||
virtual ~InvalidClassException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(InvalidClassException);
|
||||
@@ -156,7 +156,8 @@ public:
|
||||
|
||||
class FatalErrorException : public ExtendedException {
|
||||
public:
|
||||
FatalErrorException(const char *msg) : ExtendedException("%s", msg) {}
|
||||
explicit FatalErrorException(const char *msg)
|
||||
: ExtendedException("%s", msg) {}
|
||||
FatalErrorException(int, const char *msg, ...) {
|
||||
va_list ap; va_start(ap, msg); format(msg, ap); va_end(ap);
|
||||
}
|
||||
@@ -167,14 +168,14 @@ public:
|
||||
|
||||
class UncatchableException : public ExtendedException {
|
||||
public:
|
||||
UncatchableException(const char *msg) : ExtendedException(msg) {}
|
||||
explicit UncatchableException(const char *msg) : ExtendedException(msg) {}
|
||||
virtual ~UncatchableException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(UncatchableException);
|
||||
};
|
||||
|
||||
class ClassNotFoundException : public FatalErrorException {
|
||||
public:
|
||||
ClassNotFoundException(const char *msg)
|
||||
explicit ClassNotFoundException(const char *msg)
|
||||
: FatalErrorException(msg) {}
|
||||
virtual ~ClassNotFoundException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(ClassNotFoundException);
|
||||
@@ -182,7 +183,7 @@ public:
|
||||
|
||||
class SystemCallFailure : public ExtendedException {
|
||||
public:
|
||||
SystemCallFailure(const char *func)
|
||||
explicit SystemCallFailure(const char *func)
|
||||
: ExtendedException("%s returned %d: %s.", func, errno,
|
||||
Util::safe_strerror(errno).c_str()) {}
|
||||
virtual ~SystemCallFailure() throw() {}
|
||||
@@ -217,7 +218,7 @@ public:
|
||||
va_list ap; va_start(ap, fmt); format(fmt, ap); va_end(ap);
|
||||
}
|
||||
|
||||
InvalidArgumentException(const char *param)
|
||||
explicit InvalidArgumentException(const char *param)
|
||||
: ExtendedException("Invalid argument: %s", param) {}
|
||||
|
||||
virtual ~InvalidArgumentException() throw() {}
|
||||
@@ -226,7 +227,7 @@ public:
|
||||
|
||||
class NotEnoughArgumentsException : public ExtendedException {
|
||||
public:
|
||||
NotEnoughArgumentsException(const char *funcname)
|
||||
explicit NotEnoughArgumentsException(const char *funcname)
|
||||
: ExtendedException("Not enough arguments for function %s", funcname) {}
|
||||
virtual ~NotEnoughArgumentsException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(NotEnoughArgumentsException);
|
||||
@@ -234,7 +235,7 @@ public:
|
||||
|
||||
class TooManyArgumentsException : public ExtendedException {
|
||||
public:
|
||||
TooManyArgumentsException(const char *funcname)
|
||||
explicit TooManyArgumentsException(const char *funcname)
|
||||
: ExtendedException("Too much arguments for function %s", funcname) {}
|
||||
virtual ~TooManyArgumentsException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(TooManyArgumentsException);
|
||||
@@ -242,7 +243,7 @@ public:
|
||||
|
||||
class TypeVariableChangeException : public ExtendedException {
|
||||
public:
|
||||
TypeVariableChangeException(const char *loc)
|
||||
explicit TypeVariableChangeException(const char *loc)
|
||||
: ExtendedException("Type of variable changed at %s", loc) {}
|
||||
virtual ~TypeVariableChangeException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(TypeVariableChangeException);
|
||||
@@ -250,7 +251,7 @@ public:
|
||||
|
||||
class UseOfUndefinedVarException : public ExtendedException {
|
||||
public:
|
||||
UseOfUndefinedVarException(const char *loc)
|
||||
explicit UseOfUndefinedVarException(const char *loc)
|
||||
: ExtendedException("Use of undefined variable at %s", loc) {}
|
||||
virtual ~UseOfUndefinedVarException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(UseOfUndefinedVarException);
|
||||
@@ -258,7 +259,7 @@ public:
|
||||
|
||||
class MethodSignatureChangeException : public ExtendedException {
|
||||
public:
|
||||
MethodSignatureChangeException(const char *method)
|
||||
explicit MethodSignatureChangeException(const char *method)
|
||||
: ExtendedException("Signature of method %s changed", method) {}
|
||||
virtual ~MethodSignatureChangeException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(MethodSignatureChangeException);
|
||||
@@ -274,7 +275,7 @@ public:
|
||||
|
||||
class NotImplementedException : public ExtendedException {
|
||||
public:
|
||||
NotImplementedException(const char *feature)
|
||||
explicit NotImplementedException(const char *feature)
|
||||
: ExtendedException("%s is not implemented yet.", feature) {}
|
||||
virtual ~NotImplementedException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(NotImplementedException);
|
||||
@@ -293,7 +294,7 @@ class ExitException : public ExtendedException {
|
||||
public:
|
||||
static int ExitCode;
|
||||
|
||||
ExitException(int exitCode) {
|
||||
explicit ExitException(int exitCode) {
|
||||
m_handled = false;
|
||||
ExitCode = exitCode;
|
||||
}
|
||||
@@ -303,7 +304,7 @@ public:
|
||||
|
||||
class PhpFileDoesNotExistException : public ExtendedException {
|
||||
public:
|
||||
PhpFileDoesNotExistException(const char *file)
|
||||
explicit PhpFileDoesNotExistException(const char *file)
|
||||
: ExtendedException("File could not be loaded: %s", file) {}
|
||||
virtual ~PhpFileDoesNotExistException() throw() {}
|
||||
EXCEPTION_COMMON_IMPL(PhpFileDoesNotExistException);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ThriftBuffer::ThriftBuffer(int size,
|
||||
int sType /* = VariableSerializer::Serialize*/)
|
||||
VariableSerializer::Type sType /* = Serialize*/)
|
||||
: m_size(size), m_safe(false), m_serializerType(sType) {
|
||||
m_buf = (char *)malloc(m_size + 1);
|
||||
if (!m_buf) throwOutOfMemory();
|
||||
@@ -193,7 +193,7 @@ void ThriftBuffer::throwInvalidStringSize(int size) {
|
||||
|
||||
static Variant unserialize_with_no_notice(CStrRef str) {
|
||||
VariableUnserializer vu(str.data(), str.data() + str.size(),
|
||||
VariableUnserializer::Serialize, true);
|
||||
VariableUnserializer::Type::Serialize, true);
|
||||
Variant v;
|
||||
try {
|
||||
v = vu.unserialize();
|
||||
@@ -237,7 +237,7 @@ void ThriftBuffer::read(Array &data) {
|
||||
}
|
||||
|
||||
void ThriftBuffer::write(CArrRef data) {
|
||||
VariableSerializer vs((VariableSerializer::Type)m_serializerType);
|
||||
VariableSerializer vs(m_serializerType);
|
||||
String sdata = vs.serialize(VarNR(data), true);
|
||||
write(sdata);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ void ThriftBuffer::read(Object &data) {
|
||||
}
|
||||
|
||||
void ThriftBuffer::write(CObjRef data) {
|
||||
VariableSerializer vs((VariableSerializer::Type)m_serializerType);
|
||||
VariableSerializer vs(m_serializerType);
|
||||
String sdata = vs.serialize(VarNR(data), true);
|
||||
write(sdata);
|
||||
}
|
||||
@@ -261,7 +261,7 @@ void ThriftBuffer::read(Variant &data) {
|
||||
}
|
||||
|
||||
void ThriftBuffer::write(CVarRef data) {
|
||||
VariableSerializer vs((VariableSerializer::Type)m_serializerType);
|
||||
VariableSerializer vs(m_serializerType);
|
||||
String sdata = vs.serialize(data, true);
|
||||
write(sdata);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,9 @@ public:
|
||||
* Constructing with some initial size, subsequent allocation will double
|
||||
* existing size every round.
|
||||
*/
|
||||
ThriftBuffer(int size, int sType = VariableSerializer::Serialize);
|
||||
explicit ThriftBuffer(
|
||||
int size,
|
||||
VariableSerializer::Type sType = VariableSerializer::Type::Serialize);
|
||||
~ThriftBuffer();
|
||||
|
||||
void flush(); // write bytes to transport
|
||||
@@ -271,7 +273,7 @@ private:
|
||||
|
||||
char *m_buf;
|
||||
|
||||
int m_serializerType;
|
||||
VariableSerializer::Type m_serializerType;
|
||||
|
||||
void flush(CStrRef data);
|
||||
void read(char *data, int len);
|
||||
|
||||
@@ -44,7 +44,9 @@ VariableSerializer::VariableSerializer(Type type, int option /* = 0 */,
|
||||
m_valueCount(0), m_referenced(false), m_refCount(1), m_maxCount(maxRecur),
|
||||
m_levelDebugger(0) {
|
||||
m_maxLevelDebugger = g_context->getDebuggerPrintLevel();
|
||||
if (type == Serialize || type == APCSerialize || type == DebuggerSerialize) {
|
||||
if (type == Type::Serialize ||
|
||||
type == Type::APCSerialize ||
|
||||
type == Type::DebuggerSerialize) {
|
||||
m_arrayIds = new SmartPtrCtrMap();
|
||||
} else {
|
||||
m_arrayIds = nullptr;
|
||||
@@ -100,8 +102,8 @@ String VariableSerializer::serializeValue(CVarRef v, bool limit) {
|
||||
}
|
||||
|
||||
String VariableSerializer::serializeWithLimit(CVarRef v, int limit) {
|
||||
if (m_type == Serialize || m_type == JSON || m_type == APCSerialize ||
|
||||
m_type == DebuggerSerialize) {
|
||||
if (m_type == Type::Serialize || m_type == Type::JSON ||
|
||||
m_type == Type::APCSerialize || m_type == Type::DebuggerSerialize) {
|
||||
assert(false);
|
||||
return null_string;
|
||||
}
|
||||
@@ -125,25 +127,25 @@ String VariableSerializer::serializeWithLimit(CVarRef v, int limit) {
|
||||
|
||||
void VariableSerializer::write(bool v) {
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case Type::PrintR:
|
||||
if (v) m_buf->append(1);
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case JSON:
|
||||
case DebuggerDump:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
case Type::JSON:
|
||||
case Type::DebuggerDump:
|
||||
m_buf->append(v ? "true" : "false");
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
indent();
|
||||
m_buf->append(v ? "bool(true)" : "bool(false)");
|
||||
writeRefCount();
|
||||
m_buf->append('\n');
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append(v ? "b:1;" : "b:0;");
|
||||
break;
|
||||
default:
|
||||
@@ -154,20 +156,20 @@ void VariableSerializer::write(bool v) {
|
||||
|
||||
void VariableSerializer::write(int64_t v) {
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case JSON:
|
||||
case DebuggerDump:
|
||||
case Type::PrintR:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
case Type::JSON:
|
||||
case Type::DebuggerDump:
|
||||
m_buf->append(v);
|
||||
break;
|
||||
case VarDump:
|
||||
case Type::VarDump:
|
||||
indent();
|
||||
m_buf->append("int(");
|
||||
m_buf->append(v);
|
||||
m_buf->append(")\n");
|
||||
break;
|
||||
case DebugDump:
|
||||
case Type::DebugDump:
|
||||
indent();
|
||||
m_buf->append("long(");
|
||||
m_buf->append(v);
|
||||
@@ -175,9 +177,9 @@ void VariableSerializer::write(int64_t v) {
|
||||
writeRefCount();
|
||||
m_buf->append('\n');
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append("i:");
|
||||
m_buf->append(v);
|
||||
m_buf->append(';');
|
||||
@@ -190,7 +192,7 @@ void VariableSerializer::write(int64_t v) {
|
||||
|
||||
void VariableSerializer::write(double v) {
|
||||
switch (m_type) {
|
||||
case JSON:
|
||||
case Type::JSON:
|
||||
if (!std::isinf(v) && !std::isnan(v)) {
|
||||
char *buf;
|
||||
if (v == 0.0) v = 0.0; // so to avoid "-0" output
|
||||
@@ -203,26 +205,26 @@ void VariableSerializer::write(double v) {
|
||||
m_buf->append('0');
|
||||
}
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case PrintR:
|
||||
case DebuggerDump:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
case Type::PrintR:
|
||||
case Type::DebuggerDump:
|
||||
{
|
||||
char *buf;
|
||||
if (v == 0.0) v = 0.0; // so to avoid "-0" output
|
||||
bool isExport = m_type == VarExport || m_type == PHPOutput;
|
||||
bool isExport = m_type == Type::VarExport || m_type == Type::PHPOutput;
|
||||
vspprintf(&buf, 0, isExport ? "%.*H" : "%.*G", 14, v);
|
||||
m_buf->append(buf);
|
||||
// In PHPOutput mode, we always want doubles to parse as
|
||||
// doubles, so make sure there's a decimal point.
|
||||
if (m_type == PHPOutput && strpbrk(buf, ".E") == nullptr) {
|
||||
if (m_type == Type::PHPOutput && strpbrk(buf, ".E") == nullptr) {
|
||||
m_buf->append(".0");
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
{
|
||||
char *buf;
|
||||
if (v == 0.0) v = 0.0; // so to avoid "-0" output
|
||||
@@ -234,9 +236,9 @@ void VariableSerializer::write(double v) {
|
||||
m_buf->append('\n');
|
||||
}
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append("d:");
|
||||
if (std::isnan(v)) {
|
||||
m_buf->append("NAN");
|
||||
@@ -264,11 +266,11 @@ void VariableSerializer::write(const char *v, int len /* = -1 */,
|
||||
if (len < 0) len = strlen(v);
|
||||
|
||||
switch (m_type) {
|
||||
case PrintR: {
|
||||
case Type::PrintR: {
|
||||
m_buf->append(v, len);
|
||||
break;
|
||||
}
|
||||
case VarExport: {
|
||||
case Type::VarExport: {
|
||||
m_buf->append('\'');
|
||||
const char *p = v;
|
||||
for (int i = 0; i < len; i++, p++) {
|
||||
@@ -285,8 +287,8 @@ void VariableSerializer::write(const char *v, int len /* = -1 */,
|
||||
m_buf->append('\'');
|
||||
break;
|
||||
}
|
||||
case VarDump:
|
||||
case DebugDump: {
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump: {
|
||||
indent();
|
||||
m_buf->append("string(");
|
||||
m_buf->append(len);
|
||||
@@ -297,16 +299,16 @@ void VariableSerializer::write(const char *v, int len /* = -1 */,
|
||||
m_buf->append('\n');
|
||||
break;
|
||||
}
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append("s:");
|
||||
m_buf->append(len);
|
||||
m_buf->append(":\"");
|
||||
m_buf->append(v, len);
|
||||
m_buf->append("\";");
|
||||
break;
|
||||
case JSON: {
|
||||
case Type::JSON: {
|
||||
if (m_option & k_JSON_NUMERIC_CHECK) {
|
||||
int64_t lval; double dval;
|
||||
switch (is_numeric_string(v, len, &lval, &dval, 0)) {
|
||||
@@ -324,8 +326,8 @@ void VariableSerializer::write(const char *v, int len /* = -1 */,
|
||||
m_buf->appendJsonEscape(v, len, m_option);
|
||||
break;
|
||||
}
|
||||
case DebuggerDump:
|
||||
case PHPOutput: {
|
||||
case Type::DebuggerDump:
|
||||
case Type::PHPOutput: {
|
||||
m_buf->append('"');
|
||||
for (int i = 0; i < len; ++i) {
|
||||
const unsigned char c = v[i];
|
||||
@@ -359,7 +361,7 @@ void VariableSerializer::write(const char *v, int len /* = -1 */,
|
||||
}
|
||||
|
||||
void VariableSerializer::write(CStrRef v) {
|
||||
if (m_type == APCSerialize && !v.isNull() && v->isStatic()) {
|
||||
if (m_type == Type::APCSerialize && !v.isNull() && v->isStatic()) {
|
||||
union {
|
||||
char buf[8];
|
||||
StringData *sd;
|
||||
@@ -374,7 +376,7 @@ void VariableSerializer::write(CStrRef v) {
|
||||
}
|
||||
|
||||
void VariableSerializer::write(CObjRef v) {
|
||||
if (!v.isNull() && m_type == JSON) {
|
||||
if (!v.isNull() && m_type == Type::JSON) {
|
||||
|
||||
if (v.instanceof(SystemLib::s_JsonSerializableClass)) {
|
||||
assert(!v->isCollection());
|
||||
@@ -415,27 +417,27 @@ void VariableSerializer::write(CVarRef v, bool isArrayKey /* = false */) {
|
||||
|
||||
void VariableSerializer::writeNull() {
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case Type::PrintR:
|
||||
// do nothing
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
m_buf->append("NULL");
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
indent();
|
||||
m_buf->append("NULL");
|
||||
writeRefCount();
|
||||
m_buf->append('\n');
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append("N;");
|
||||
break;
|
||||
case JSON:
|
||||
case DebuggerDump:
|
||||
case Type::JSON:
|
||||
case Type::DebuggerDump:
|
||||
m_buf->append("null");
|
||||
break;
|
||||
default:
|
||||
@@ -448,7 +450,7 @@ void VariableSerializer::writeOverflow(void* ptr, bool isObject /* = false */) {
|
||||
bool wasRef = m_referenced;
|
||||
setReferenced(false);
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case Type::PrintR:
|
||||
if (!m_objClass.empty()) {
|
||||
m_buf->append(m_objClass);
|
||||
m_buf->append(" Object\n");
|
||||
@@ -457,24 +459,24 @@ void VariableSerializer::writeOverflow(void* ptr, bool isObject /* = false */) {
|
||||
}
|
||||
m_buf->append(" *RECURSION*");
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
throw NestingLevelTooDeepException();
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case DebuggerDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
case Type::DebuggerDump:
|
||||
indent();
|
||||
m_buf->append("*RECURSION*\n");
|
||||
break;
|
||||
case DebuggerSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
if (m_maxLevelDebugger > 0 && m_levelDebugger > m_maxLevelDebugger) {
|
||||
// Not recursion, just cut short of print
|
||||
m_buf->append("s:12:\"...(omitted)\";", 20);
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
{
|
||||
assert(m_arrayIds);
|
||||
SmartPtrCtrMap::const_iterator iter = m_arrayIds->find(ptr);
|
||||
@@ -493,7 +495,7 @@ void VariableSerializer::writeOverflow(void* ptr, bool isObject /* = false */) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case JSON:
|
||||
case Type::JSON:
|
||||
raise_warning("json_encode(): recursion detected");
|
||||
m_buf->append("null");
|
||||
break;
|
||||
@@ -504,7 +506,7 @@ void VariableSerializer::writeOverflow(void* ptr, bool isObject /* = false */) {
|
||||
}
|
||||
|
||||
void VariableSerializer::writeRefCount() {
|
||||
if (m_type == DebugDump) {
|
||||
if (m_type == Type::DebugDump) {
|
||||
m_buf->append(" refcount(");
|
||||
m_buf->append(m_refCount);
|
||||
m_buf->append(')');
|
||||
@@ -519,8 +521,8 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
info.indent_delta = 0;
|
||||
|
||||
switch (m_type) {
|
||||
case DebuggerDump:
|
||||
case PrintR:
|
||||
case Type::DebuggerDump:
|
||||
case Type::PrintR:
|
||||
if (!m_rsrcName.empty()) {
|
||||
m_buf->append("Resource id #");
|
||||
m_buf->append(m_rsrcId);
|
||||
@@ -538,8 +540,8 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
m_buf->append("(\n");
|
||||
m_indent += (info.indent_delta = 4);
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
if (m_indent > 0) {
|
||||
m_buf->append('\n');
|
||||
indent();
|
||||
@@ -557,8 +559,8 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
}
|
||||
m_indent += (info.indent_delta = 2);
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
indent();
|
||||
if (!m_rsrcName.empty()) {
|
||||
m_buf->append("resource(");
|
||||
@@ -581,7 +583,7 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
m_buf->append(')');
|
||||
|
||||
// ...so to strictly follow PHP's output
|
||||
if (m_type == VarDump) {
|
||||
if (m_type == Type::VarDump) {
|
||||
m_buf->append(' ');
|
||||
} else {
|
||||
writeRefCount();
|
||||
@@ -590,9 +592,9 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
m_buf->append("{\n");
|
||||
m_indent += (info.indent_delta = 2);
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
if (!m_objClass.empty()) {
|
||||
m_buf->append(m_objCode);
|
||||
m_buf->append(":");
|
||||
@@ -608,11 +610,11 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
m_buf->append(":{");
|
||||
}
|
||||
break;
|
||||
case JSON:
|
||||
case Type::JSON:
|
||||
info.is_vector =
|
||||
(m_objClass.empty() || m_objCode == 'V' || m_objCode == 'K') &&
|
||||
isVectorData;
|
||||
if (info.is_vector && m_type == JSON) {
|
||||
if (info.is_vector && m_type == Type::JSON) {
|
||||
info.is_vector = (m_option & k_JSON_FORCE_OBJECT)
|
||||
? false : info.is_vector;
|
||||
}
|
||||
@@ -623,7 +625,7 @@ void VariableSerializer::writeArrayHeader(int size, bool isVectorData) {
|
||||
m_buf->append('{');
|
||||
}
|
||||
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
if (m_type == Type::JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_indent += (info.indent_delta = 4);
|
||||
}
|
||||
|
||||
@@ -651,12 +653,12 @@ void VariableSerializer::writePropertyKey(CStrRef prop) {
|
||||
assert(key[2] == 0);
|
||||
m_buf->append(key + 3, kl - 3);
|
||||
const char prot[] = "\":protected";
|
||||
int o = m_type == PrintR ? 1 : 0;
|
||||
int o = m_type == Type::PrintR ? 1 : 0;
|
||||
m_buf->append(prot + o, sizeof(prot) - 1 - o);
|
||||
} else {
|
||||
int l = strlen(cls);
|
||||
m_buf->append(cls + l + 1, kl - l - 2);
|
||||
int o = m_type == PrintR ? 1 : 0;
|
||||
int o = m_type == Type::PrintR ? 1 : 0;
|
||||
m_buf->append(&"\":\""[o], 3 - 2*o);
|
||||
m_buf->append(cls, l);
|
||||
const char priv[] = "\":private";
|
||||
@@ -664,7 +666,9 @@ void VariableSerializer::writePropertyKey(CStrRef prop) {
|
||||
}
|
||||
} else {
|
||||
m_buf->append(prop);
|
||||
if (m_type != PrintR && m_type != DebuggerDump) m_buf->append('"');
|
||||
if (m_type != Type::PrintR && m_type != Type::DebuggerDump) {
|
||||
m_buf->append('"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,15 +677,15 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
auto const keyCell = key.asCell();
|
||||
bool const skey = IS_STRING_TYPE(keyCell->m_type);
|
||||
|
||||
if (skey && m_type == APCSerialize) {
|
||||
if (skey && m_type == Type::APCSerialize) {
|
||||
write(StrNR(keyCell->m_data.pstr).asString());
|
||||
return;
|
||||
}
|
||||
ArrayInfo &info = m_arrayInfos.back();
|
||||
|
||||
switch (m_type) {
|
||||
case DebuggerDump:
|
||||
case PrintR: {
|
||||
case Type::DebuggerDump:
|
||||
case Type::PrintR: {
|
||||
indent();
|
||||
m_buf->append('[');
|
||||
if (info.is_object && skey) {
|
||||
@@ -693,15 +697,15 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
break;
|
||||
}
|
||||
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
indent();
|
||||
write(key, true);
|
||||
m_buf->append(" => ");
|
||||
break;
|
||||
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
indent();
|
||||
m_buf->append('[');
|
||||
if (!skey) {
|
||||
@@ -718,17 +722,17 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
m_buf->append("]=>\n");
|
||||
break;
|
||||
|
||||
case APCSerialize:
|
||||
case Serialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::DebuggerSerialize:
|
||||
write(key);
|
||||
break;
|
||||
|
||||
case JSON:
|
||||
case Type::JSON:
|
||||
if (!info.first_element) {
|
||||
m_buf->append(',');
|
||||
}
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
if (m_type == Type::JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_buf->append("\n");
|
||||
indent();
|
||||
}
|
||||
@@ -749,7 +753,7 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
m_buf->append('"');
|
||||
}
|
||||
m_buf->append(':');
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
if (m_type == Type::JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_buf->append(' ');
|
||||
}
|
||||
}
|
||||
@@ -762,8 +766,8 @@ void VariableSerializer::writeArrayKey(Variant key) {
|
||||
}
|
||||
|
||||
void VariableSerializer::writeCollectionKey(CVarRef key) {
|
||||
if (m_type == Serialize || m_type == APCSerialize ||
|
||||
m_type == DebuggerSerialize) {
|
||||
if (m_type == Type::Serialize || m_type == Type::APCSerialize ||
|
||||
m_type == Type::DebuggerSerialize) {
|
||||
m_valueCount++;
|
||||
}
|
||||
writeArrayKey(key);
|
||||
@@ -771,24 +775,24 @@ void VariableSerializer::writeCollectionKey(CVarRef key) {
|
||||
|
||||
void VariableSerializer::writeCollectionKeylessPrefix() {
|
||||
switch (m_type) {
|
||||
case PrintR:
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::PrintR:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
indent();
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case APCSerialize:
|
||||
case Serialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
case Type::APCSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::DebuggerSerialize:
|
||||
break;
|
||||
case JSON:
|
||||
case DebuggerDump: {
|
||||
case Type::JSON:
|
||||
case Type::DebuggerDump: {
|
||||
ArrayInfo &info = m_arrayInfos.back();
|
||||
if (!info.first_element) {
|
||||
m_buf->append(',');
|
||||
}
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
if (m_type == Type::JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_buf->append("\n");
|
||||
indent();
|
||||
}
|
||||
@@ -802,8 +806,8 @@ void VariableSerializer::writeCollectionKeylessPrefix() {
|
||||
|
||||
void VariableSerializer::writeArrayValue(CVarRef value) {
|
||||
// Do not count referenced values after the first
|
||||
if ((m_type == Serialize || m_type == APCSerialize ||
|
||||
m_type == DebuggerSerialize) &&
|
||||
if ((m_type == Type::Serialize || m_type == Type::APCSerialize ||
|
||||
m_type == Type::DebuggerSerialize) &&
|
||||
!(value.isReferenced() &&
|
||||
m_arrayIds->find(value.getRefData()) != m_arrayIds->end())) {
|
||||
m_valueCount++;
|
||||
@@ -811,12 +815,12 @@ void VariableSerializer::writeArrayValue(CVarRef value) {
|
||||
|
||||
write(value);
|
||||
switch (m_type) {
|
||||
case DebuggerDump:
|
||||
case PrintR:
|
||||
case Type::DebuggerDump:
|
||||
case Type::PrintR:
|
||||
m_buf->append('\n');
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
m_buf->append(",\n");
|
||||
break;
|
||||
default:
|
||||
@@ -832,8 +836,8 @@ void VariableSerializer::writeArrayFooter() {
|
||||
|
||||
m_indent -= info.indent_delta;
|
||||
switch (m_type) {
|
||||
case DebuggerDump:
|
||||
case PrintR:
|
||||
case Type::DebuggerDump:
|
||||
case Type::PrintR:
|
||||
if (m_rsrcName.empty()) {
|
||||
indent();
|
||||
m_buf->append(")\n");
|
||||
@@ -842,8 +846,8 @@ void VariableSerializer::writeArrayFooter() {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
indent();
|
||||
if (info.is_object) {
|
||||
if (m_objCode == 'O') {
|
||||
@@ -856,20 +860,20 @@ void VariableSerializer::writeArrayFooter() {
|
||||
m_buf->append(')');
|
||||
}
|
||||
break;
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
if (m_rsrcName.empty()) {
|
||||
indent();
|
||||
m_buf->append("}\n");
|
||||
}
|
||||
break;
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case DebuggerSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
m_buf->append('}');
|
||||
break;
|
||||
case JSON:
|
||||
if (m_type == JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
case Type::JSON:
|
||||
if (m_type == Type::JSON && m_option & k_JSON_PRETTY_PRINT) {
|
||||
m_buf->append("\n");
|
||||
indent();
|
||||
}
|
||||
@@ -907,7 +911,7 @@ void VariableSerializer::indent() {
|
||||
m_buf->append(' ');
|
||||
}
|
||||
if (m_referenced) {
|
||||
if (m_indent > 0 && m_type == VarDump) m_buf->append('&');
|
||||
if (m_indent > 0 && m_type == Type::VarDump) m_buf->append('&');
|
||||
m_referenced = false;
|
||||
}
|
||||
}
|
||||
@@ -915,21 +919,21 @@ void VariableSerializer::indent() {
|
||||
bool VariableSerializer::incNestedLevel(void *ptr,
|
||||
bool isObject /* = false */) {
|
||||
switch (m_type) {
|
||||
case VarExport:
|
||||
case PHPOutput:
|
||||
case PrintR:
|
||||
case VarDump:
|
||||
case DebugDump:
|
||||
case JSON:
|
||||
case DebuggerDump:
|
||||
case Type::VarExport:
|
||||
case Type::PHPOutput:
|
||||
case Type::PrintR:
|
||||
case Type::VarDump:
|
||||
case Type::DebugDump:
|
||||
case Type::JSON:
|
||||
case Type::DebuggerDump:
|
||||
return ++m_counts[ptr] >= m_maxCount;
|
||||
case DebuggerSerialize:
|
||||
case Type::DebuggerSerialize:
|
||||
if (m_maxLevelDebugger > 0 && ++m_levelDebugger > m_maxLevelDebugger) {
|
||||
return true;
|
||||
}
|
||||
// fall through
|
||||
case Serialize:
|
||||
case APCSerialize:
|
||||
case Type::Serialize:
|
||||
case Type::APCSerialize:
|
||||
{
|
||||
assert(m_arrayIds);
|
||||
int ct = ++m_counts[ptr];
|
||||
@@ -951,7 +955,7 @@ bool VariableSerializer::incNestedLevel(void *ptr,
|
||||
|
||||
void VariableSerializer::decNestedLevel(void *ptr) {
|
||||
--m_counts[ptr];
|
||||
if (m_type == DebuggerSerialize && m_maxLevelDebugger > 0) {
|
||||
if (m_type == Type::DebuggerSerialize && m_maxLevelDebugger > 0) {
|
||||
--m_levelDebugger;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
/**
|
||||
* Supported formats.
|
||||
*/
|
||||
enum Type {
|
||||
enum class Type {
|
||||
PrintR, //print_r()
|
||||
VarExport, //var_export()
|
||||
VarDump, //var_dump()
|
||||
|
||||
@@ -31,7 +31,7 @@ Variant VariableUnserializer::unserialize() {
|
||||
|
||||
Variant VariableUnserializer::unserializeKey() {
|
||||
Variant v;
|
||||
v.unserialize(this, Uns::KeyMode);
|
||||
v.unserialize(this, Uns::Mode::Key);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ Variant &VariableUnserializer::addVar() {
|
||||
}
|
||||
|
||||
bool VariableUnserializer::isWhitelistedClass(CStrRef cls_name) const {
|
||||
if (m_type != Serialize || m_classWhiteList.isNull()) {
|
||||
if (m_type != Type::Serialize || m_classWhiteList.isNull()) {
|
||||
return true;
|
||||
}
|
||||
if (!m_classWhiteList.isNull() && !m_classWhiteList.empty()) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
/**
|
||||
* Supported formats.
|
||||
*/
|
||||
enum Type {
|
||||
enum class Type {
|
||||
Serialize,
|
||||
APCSerialize,
|
||||
};
|
||||
@@ -59,14 +59,14 @@ public:
|
||||
Variant unserialize();
|
||||
Variant unserializeKey();
|
||||
void add(Variant* v, Uns::Mode mode) {
|
||||
if (mode == Uns::ValueMode) {
|
||||
if (mode == Uns::Mode::Value) {
|
||||
m_refs.emplace_back(RefInfo(v));
|
||||
} else if (mode == Uns::KeyMode) {
|
||||
} else if (mode == Uns::Mode::Key) {
|
||||
// do nothing
|
||||
} else if (mode == Uns::ColValueMode) {
|
||||
} else if (mode == Uns::Mode::ColValue) {
|
||||
m_refs.emplace_back(RefInfo::makeNonRefable(v));
|
||||
} else {
|
||||
assert(mode == Uns::ColKeyMode);
|
||||
assert(mode == Uns::Mode::ColKey);
|
||||
// We don't currently support using the 'r' encoding to refer
|
||||
// to collection keys, but eventually we'll need to make this
|
||||
// work to allow objects as keys. For now we encode collections
|
||||
|
||||
@@ -64,23 +64,23 @@ std::string CmdPrint::FormatResult(const char *format, CVarRef ret) {
|
||||
StringBuffer sb;
|
||||
DateTime dt(nret);
|
||||
sb.append("RFC822: ");
|
||||
sb.append(dt.toString(DateTime::RFC822));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC822));
|
||||
sb.append("\nRFC850: ");
|
||||
sb.append(dt.toString(DateTime::RFC850));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC850));
|
||||
sb.append("\nRFC1036: ");
|
||||
sb.append(dt.toString(DateTime::RFC1036));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC1036));
|
||||
sb.append("\nRFC1123/RSS: ");
|
||||
sb.append(dt.toString(DateTime::RFC1123));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC1123));
|
||||
sb.append("\nRFC2822: ");
|
||||
sb.append(dt.toString(DateTime::RFC2822));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC2822));
|
||||
sb.append("\nRFC3339/ATOM/W3C: ");
|
||||
sb.append(dt.toString(DateTime::RFC3339));
|
||||
sb.append(dt.toString(DateTime::DateFormat::RFC3339));
|
||||
sb.append("\nISO8601: ");
|
||||
sb.append(dt.toString(DateTime::ISO8601));
|
||||
sb.append(dt.toString(DateTime::DateFormat::ISO8601));
|
||||
sb.append("\nCookie: ");
|
||||
sb.append(dt.toString(DateTime::Cookie));
|
||||
sb.append(dt.toString(DateTime::DateFormat::Cookie));
|
||||
sb.append("\nHttpHeader: ");
|
||||
sb.append(dt.toString(DateTime::HttpHeader));
|
||||
sb.append(dt.toString(DateTime::DateFormat::HttpHeader));
|
||||
return sb.data();
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ void CmdPrint::processList(DebuggerClient &client) {
|
||||
for (int i = 0; i < (int)watches.size(); i++) {
|
||||
client.print(" %d %s %s", i + 1,
|
||||
StringUtil::Pad(watches[i]->first, 8, " ",
|
||||
StringUtil::PadLeft).data(),
|
||||
StringUtil::PadType::Left).data(),
|
||||
watches[i]->second.c_str());
|
||||
}
|
||||
if (watches.empty()) {
|
||||
|
||||
@@ -331,8 +331,8 @@ String DebuggerClient::FormatVariable(CVarRef v, int maxlen /* = 80 */,
|
||||
if (maxlen <= 0) {
|
||||
try {
|
||||
VariableSerializer::Type t = vardump ?
|
||||
VariableSerializer::VarDump :
|
||||
VariableSerializer::DebuggerDump;
|
||||
VariableSerializer::Type::VarDump :
|
||||
VariableSerializer::Type::DebuggerDump;
|
||||
VariableSerializer vs(t, 0, 2);
|
||||
value = vs.serialize(v, true);
|
||||
} catch (StringBufferLimitException &e) {
|
||||
@@ -342,7 +342,7 @@ String DebuggerClient::FormatVariable(CVarRef v, int maxlen /* = 80 */,
|
||||
throw;
|
||||
}
|
||||
} else {
|
||||
VariableSerializer vs(VariableSerializer::DebuggerDump, 0, 2);
|
||||
VariableSerializer vs(VariableSerializer::Type::DebuggerDump, 0, 2);
|
||||
value = vs.serializeWithLimit(v, maxlen);
|
||||
}
|
||||
|
||||
@@ -1512,7 +1512,7 @@ void DebuggerClient::helpCmds(const std::vector<const char *> &cmds) {
|
||||
line.append(" ");
|
||||
line.append(lines2[n].toString());
|
||||
|
||||
sb.append(StringUtil::Trim(line.detach(), StringUtil::TrimRight));
|
||||
sb.append(StringUtil::Trim(line.detach(), StringUtil::TrimType::Right));
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ static StaticString s_type_mismatch(LITSTR_INIT("Type mismatch"));
|
||||
template<typename T>
|
||||
static inline int serializeImpl(T data, String& sdata) {
|
||||
TRACE(2, "DebuggerWireHelpers::serializeImpl\n");
|
||||
VariableSerializer vs(VariableSerializer::DebuggerSerialize);
|
||||
VariableSerializer vs(VariableSerializer::Type::DebuggerSerialize);
|
||||
try {
|
||||
sdata = vs.serialize(data, true);
|
||||
} catch (StringBufferLimitException &e) {
|
||||
@@ -71,7 +71,7 @@ static inline int unserializeImpl(CStrRef sdata, Variant& data) {
|
||||
return DebuggerWireHelpers::UnknownError;
|
||||
}
|
||||
VariableUnserializer vu(sdata.data(), sdata.size(),
|
||||
VariableUnserializer::Serialize, true);
|
||||
VariableUnserializer::Type::Serialize, true);
|
||||
try {
|
||||
data = vu.unserialize();
|
||||
} catch (Exception &e) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
public:
|
||||
DebuggerThriftBuffer()
|
||||
: ThriftBuffer(BUFFER_SIZE, VariableSerializer::DebuggerSerialize) {}
|
||||
: ThriftBuffer(BUFFER_SIZE, VariableSerializer::Type::DebuggerSerialize) {}
|
||||
|
||||
SmartPtr<Socket> getSocket() { return m_socket;}
|
||||
|
||||
|
||||
@@ -1129,8 +1129,8 @@ int apc_rfc1867_progress(apc_rfc1867_data *rfc1867ApcData,
|
||||
String apc_serialize(CVarRef value) {
|
||||
VariableSerializer::Type sType =
|
||||
RuntimeOption::EnableApcSerialize ?
|
||||
VariableSerializer::APCSerialize :
|
||||
VariableSerializer::Serialize;
|
||||
VariableSerializer::Type::APCSerialize :
|
||||
VariableSerializer::Type::Serialize;
|
||||
VariableSerializer vs(sType);
|
||||
return vs.serialize(value, true);
|
||||
}
|
||||
@@ -1138,8 +1138,8 @@ String apc_serialize(CVarRef value) {
|
||||
Variant apc_unserialize(CStrRef str) {
|
||||
VariableUnserializer::Type sType =
|
||||
RuntimeOption::EnableApcSerialize ?
|
||||
VariableUnserializer::APCSerialize :
|
||||
VariableUnserializer::Serialize;
|
||||
VariableUnserializer::Type::APCSerialize :
|
||||
VariableUnserializer::Type::Serialize;
|
||||
return unserialize_ex(str, sType);
|
||||
}
|
||||
|
||||
@@ -1289,7 +1289,7 @@ String apc_reserialize(CStrRef str) {
|
||||
!RuntimeOption::EnableApcSerialize) return str;
|
||||
|
||||
VariableUnserializer uns(str.data(), str.size(),
|
||||
VariableUnserializer::APCSerialize);
|
||||
VariableUnserializer::Type::APCSerialize);
|
||||
StringBuffer buf;
|
||||
reserialize(&uns, buf);
|
||||
|
||||
|
||||
@@ -950,7 +950,7 @@ void c_Vector::Unserialize(ObjectData* obj,
|
||||
auto tv = &vec->m_data[vec->m_size];
|
||||
tv->m_type = KindOfNull;
|
||||
++vec->m_size;
|
||||
tvAsVariant(tv).unserialize(uns, Uns::ColValueMode);
|
||||
tvAsVariant(tv).unserialize(uns, Uns::Mode::ColValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2078,7 +2078,7 @@ void c_Map::Unserialize(ObjectData* obj,
|
||||
mp->reserve(sz);
|
||||
for (int64_t i = 0; i < sz; ++i) {
|
||||
Variant k;
|
||||
k.unserialize(uns, Uns::ColKeyMode);
|
||||
k.unserialize(uns, Uns::Mode::ColKey);
|
||||
Bucket* p;
|
||||
if (k.isInteger()) {
|
||||
auto h = k.toInt64();
|
||||
@@ -2098,7 +2098,7 @@ void c_Map::Unserialize(ObjectData* obj,
|
||||
++mp->m_load;
|
||||
p->data.m_type = KindOfNull;
|
||||
do_unserialize:
|
||||
tvAsVariant(&p->data).unserialize(uns, Uns::ColValueMode);
|
||||
tvAsVariant(&p->data).unserialize(uns, Uns::Mode::ColValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3350,7 +3350,7 @@ void c_StableMap::Unserialize(ObjectData* obj,
|
||||
smp->reserve(sz);
|
||||
for (int64_t i = 0; i < sz; ++i) {
|
||||
Variant k;
|
||||
k.unserialize(uns, Uns::ColKeyMode);
|
||||
k.unserialize(uns, Uns::Mode::ColKey);
|
||||
Bucket* p;
|
||||
uint nIndex;
|
||||
if (k.isInteger()) {
|
||||
@@ -3377,7 +3377,7 @@ void c_StableMap::Unserialize(ObjectData* obj,
|
||||
smp->m_arBuckets[nIndex] = p;
|
||||
CONNECT_TO_GLOBAL_DLLIST(smp, p);
|
||||
do_unserialize:
|
||||
tvAsVariant(&p->data).unserialize(uns, Uns::ColValueMode);
|
||||
tvAsVariant(&p->data).unserialize(uns, Uns::Mode::ColValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4158,10 +4158,10 @@ void c_Set::Unserialize(ObjectData* obj,
|
||||
st->reserve(sz);
|
||||
for (int64_t i = 0; i < sz; ++i) {
|
||||
Variant k;
|
||||
// When unserializing an element of a Set, we use ColKeyMode for now.
|
||||
// When unserializing an element of a Set, we use Mode::ColKey for now.
|
||||
// This will make the unserializer to reserve an id for the element
|
||||
// but won't allow referencing the element via 'r' or 'R'.
|
||||
k.unserialize(uns, Uns::ColKeyMode);
|
||||
k.unserialize(uns, Uns::Mode::ColKey);
|
||||
Bucket* p;
|
||||
if (k.isInteger()) {
|
||||
auto h = k.toInt64();
|
||||
@@ -4521,8 +4521,8 @@ void c_Pair::Unserialize(ObjectData* obj,
|
||||
pair->m_size = 2;
|
||||
pair->elm0.m_type = KindOfNull;
|
||||
pair->elm1.m_type = KindOfNull;
|
||||
tvAsVariant(&pair->elm0).unserialize(uns, Uns::ColValueMode);
|
||||
tvAsVariant(&pair->elm1).unserialize(uns, Uns::ColValueMode);
|
||||
tvAsVariant(&pair->elm0).unserialize(uns, Uns::Mode::ColValue);
|
||||
tvAsVariant(&pair->elm1).unserialize(uns, Uns::Mode::ColValue);
|
||||
}
|
||||
|
||||
c_PairIterator::c_PairIterator(Class* cb) :
|
||||
@@ -4600,11 +4600,11 @@ void collectionSerialize(ObjectData* obj, VariableSerializer* serializer) {
|
||||
obj->getCollectionType() == Collection::PairType) {
|
||||
serializer->setObjectInfo(obj->o_getClassName(), obj->o_getId(), 'V');
|
||||
serializer->writeArrayHeader(sz, true);
|
||||
if (serializer->getType() == VariableSerializer::Serialize ||
|
||||
serializer->getType() == VariableSerializer::APCSerialize ||
|
||||
serializer->getType() == VariableSerializer::DebuggerSerialize ||
|
||||
serializer->getType() == VariableSerializer::VarExport ||
|
||||
serializer->getType() == VariableSerializer::PHPOutput) {
|
||||
if (serializer->getType() == VariableSerializer::Type::Serialize ||
|
||||
serializer->getType() == VariableSerializer::Type::APCSerialize ||
|
||||
serializer->getType() == VariableSerializer::Type::DebuggerSerialize ||
|
||||
serializer->getType() == VariableSerializer::Type::VarExport ||
|
||||
serializer->getType() == VariableSerializer::Type::PHPOutput) {
|
||||
// For the 'V' serialization format, we don't print out keys
|
||||
// for Serialize, APCSerialize, DebuggerSerialize
|
||||
for (ArrayIter iter(obj); iter; ++iter) {
|
||||
|
||||
@@ -403,13 +403,14 @@ String f_gmstrftime(CStrRef format,
|
||||
}
|
||||
|
||||
Array f_getdate(int64_t timestamp /* = TimeStamp::Current() */) {
|
||||
return DateTime(timestamp, false).toArray(DateTime::TimeMap);
|
||||
return DateTime(timestamp, false).toArray(DateTime::ArrayFormat::TimeMap);
|
||||
}
|
||||
|
||||
Array f_localtime(int64_t timestamp /* = TimeStamp::Current() */,
|
||||
bool is_associative /* = false */) {
|
||||
DateTime::ArrayFormat format =
|
||||
is_associative ? DateTime::TmMap : DateTime::TmVector;
|
||||
is_associative ? DateTime::ArrayFormat::TmMap :
|
||||
DateTime::ArrayFormat::TmVector;
|
||||
return DateTime(timestamp, false).toArray(format);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,19 +192,19 @@ bool f_trigger_error(CStrRef error_msg,
|
||||
if (g_context->getThrowAllErrors()) throw error_type;
|
||||
if (error_type == k_E_USER_ERROR) {
|
||||
g_context->handleError(msg, error_type, true,
|
||||
ExecutionContext::ThrowIfUnhandled,
|
||||
ExecutionContext::ErrorThrowMode::IfUnhandled,
|
||||
"HipHop Recoverable error: ");
|
||||
} else if (error_type == k_E_USER_WARNING) {
|
||||
g_context->handleError(msg, error_type, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Warning: ");
|
||||
} else if (error_type == k_E_USER_NOTICE) {
|
||||
g_context->handleError(msg, error_type, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Notice: ");
|
||||
} else if (error_type == k_E_USER_DEPRECATED) {
|
||||
g_context->handleError(msg, error_type, true,
|
||||
ExecutionContext::NeverThrow,
|
||||
ExecutionContext::ErrorThrowMode::Never,
|
||||
"HipHop Deprecated: ");
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -253,7 +253,7 @@ bool f_msg_receive(CObjRef queue, int64_t desiredmsgtype, VRefParam msgtype,
|
||||
const char *bufText = (const char *)MSGBUF_MTEXT(buffer);
|
||||
uint bufLen = strlen(bufText);
|
||||
VariableUnserializer vu(bufText, bufLen,
|
||||
VariableUnserializer::Serialize);
|
||||
VariableUnserializer::Type::Serialize);
|
||||
try {
|
||||
message = vu.unserialize();
|
||||
} catch (Exception &e) {
|
||||
|
||||
@@ -45,7 +45,7 @@ String f_json_encode(CVarRef value, CVarRef options /* = 0 */) {
|
||||
json_options = k_JSON_FB_LOOSE;
|
||||
}
|
||||
|
||||
VariableSerializer vs(VariableSerializer::JSON, json_options);
|
||||
VariableSerializer vs(VariableSerializer::Type::JSON, json_options);
|
||||
return vs.serializeValue(value, !(json_options & k_JSON_FB_UNLIMITED));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ int64_t f_hphp_get_stats(CStrRef name) {
|
||||
}
|
||||
Array f_hphp_get_status() {
|
||||
std::string out;
|
||||
ServerStats::ReportStatus(out, ServerStats::JSON);
|
||||
ServerStats::ReportStatus(out, ServerStats::Format::JSON);
|
||||
return f_json_decode(String(out));
|
||||
}
|
||||
Array f_hphp_get_iostatus() {
|
||||
|
||||
@@ -453,7 +453,7 @@ String f_exec(CStrRef command, VRefParam output /* = null */,
|
||||
if (!count || lines.empty()) {
|
||||
return String();
|
||||
}
|
||||
return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
|
||||
return StringUtil::Trim(lines[count - 1], StringUtil::TrimType::Right);
|
||||
}
|
||||
|
||||
void f_passthru(CStrRef command, VRefParam return_var /* = null */) {
|
||||
@@ -499,7 +499,7 @@ String f_system(CStrRef command, VRefParam return_var /* = null */) {
|
||||
if (!count || lines.empty()) {
|
||||
return String();
|
||||
}
|
||||
return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
|
||||
return StringUtil::Trim(lines[count - 1], StringUtil::TrimType::Right);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -148,7 +148,8 @@ String f_pagelet_server_task_result(CObjRef task, VRefParam headers,
|
||||
void f_pagelet_server_flush() {
|
||||
ExecutionContext *context = g_context.getNoCheck();
|
||||
Transport *transport = context->getTransport();
|
||||
if (transport && transport->getThreadType() == Transport::PageletThread) {
|
||||
if (transport &&
|
||||
transport->getThreadType() == Transport::ThreadType::PageletThread) {
|
||||
// this method is only meaningful in a pagelet thread
|
||||
context->obFlushAll();
|
||||
String content = context->obDetachContents();
|
||||
|
||||
@@ -831,7 +831,8 @@ public:
|
||||
String key(p + 1, namelen, CopyString);
|
||||
p += namelen + 1;
|
||||
if (has_value) {
|
||||
VariableUnserializer vu(p, endptr, VariableUnserializer::Serialize);
|
||||
VariableUnserializer vu(p, endptr,
|
||||
VariableUnserializer::Type::Serialize);
|
||||
try {
|
||||
g->getRef(s__SESSION).set(key, vu.unserialize());
|
||||
p = vu.head();
|
||||
@@ -891,7 +892,8 @@ public:
|
||||
String key(p, q - p, CopyString);
|
||||
q++;
|
||||
if (has_value) {
|
||||
VariableUnserializer vu(q, endptr, VariableUnserializer::Serialize);
|
||||
VariableUnserializer vu(q, endptr,
|
||||
VariableUnserializer::Type::Serialize);
|
||||
try {
|
||||
g->getRef(s__SESSION).set(key, vu.unserialize());
|
||||
q = vu.head();
|
||||
@@ -1101,7 +1103,7 @@ static void php_session_send_cookie() {
|
||||
time_t t = tv.tv_sec + PS(cookie_lifetime);
|
||||
if (t > 0) {
|
||||
ncookie.append(COOKIE_EXPIRES);
|
||||
ncookie.append(DateTime(t).toString(DateTime::Cookie));
|
||||
ncookie.append(DateTime(t).toString(DateTime::DateFormat::Cookie));
|
||||
}
|
||||
}
|
||||
if (!PS(cookie_path).empty()) {
|
||||
|
||||
@@ -1295,7 +1295,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function,
|
||||
if (!obj->o_get("faultcode").toString().empty()) {
|
||||
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST("faultcode"));
|
||||
String str = StringUtil::HtmlEncode(obj->o_get("faultcode"),
|
||||
StringUtil::DoubleQuotes,
|
||||
StringUtil::QuoteStyle::Double,
|
||||
"UTF-8", true);
|
||||
xmlAddChild(param, node);
|
||||
if (!fault_ns.empty()) {
|
||||
@@ -1325,7 +1325,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function,
|
||||
if (!obj->o_get("faultcode").toString().empty()) {
|
||||
xmlNodePtr node = xmlNewChild(param, ns, BAD_CAST("Code"), NULL);
|
||||
String str = StringUtil::HtmlEncode(obj->o_get("faultcode"),
|
||||
StringUtil::DoubleQuotes,
|
||||
StringUtil::QuoteStyle::Double,
|
||||
"UTF-8", true);
|
||||
node = xmlNewChild(node, ns, BAD_CAST("Value"), NULL);
|
||||
if (!fault_ns.empty()) {
|
||||
@@ -2059,7 +2059,7 @@ void c_SoapServer::t_handle(CStrRef request /* = null_string */) {
|
||||
|
||||
// 0. serving WSDL
|
||||
Transport *transport = g_context->getTransport();
|
||||
if (transport && transport->getMethod() == Transport::GET &&
|
||||
if (transport && transport->getMethod() == Transport::Method::GET &&
|
||||
transport->getCommand() == "wsdl") {
|
||||
if (!m_sdl) {
|
||||
throw_soap_server_fault("Server", "WSDL generation is not supported");
|
||||
|
||||
@@ -72,31 +72,31 @@ String f_strtolower(CStrRef str) {
|
||||
return StringUtil::ToLower(str);
|
||||
}
|
||||
String f_strtoupper(CStrRef str) {
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperAll);
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperType::All);
|
||||
}
|
||||
String f_ucfirst(CStrRef str) {
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperFirst);
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperType::First);
|
||||
}
|
||||
String f_lcfirst(CStrRef str) {
|
||||
return StringUtil::ToLower(str, StringUtil::ToLowerFirst);
|
||||
return StringUtil::ToLower(str, StringUtil::ToLowerType::First);
|
||||
}
|
||||
String f_ucwords(CStrRef str) {
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperWords);
|
||||
return StringUtil::ToUpper(str, StringUtil::ToUpperType::Words);
|
||||
}
|
||||
String f_strip_tags(CStrRef str, CStrRef allowable_tags /* = "" */) {
|
||||
return StringUtil::StripHTMLTags(str, allowable_tags);
|
||||
}
|
||||
String f_trim(CStrRef str, CStrRef charlist /* = k_HPHP_TRIM_CHARLIST */) {
|
||||
return StringUtil::Trim(str, StringUtil::TrimBoth, charlist);
|
||||
return StringUtil::Trim(str, StringUtil::TrimType::Both, charlist);
|
||||
}
|
||||
String f_ltrim(CStrRef str, CStrRef charlist /* = k_HPHP_TRIM_CHARLIST */) {
|
||||
return StringUtil::Trim(str, StringUtil::TrimLeft, charlist);
|
||||
return StringUtil::Trim(str, StringUtil::TrimType::Left, charlist);
|
||||
}
|
||||
String f_rtrim(CStrRef str, CStrRef charlist /* = k_HPHP_TRIM_CHARLIST */) {
|
||||
return StringUtil::Trim(str, StringUtil::TrimRight, charlist);
|
||||
return StringUtil::Trim(str, StringUtil::TrimType::Right, charlist);
|
||||
}
|
||||
String f_chop(CStrRef str, CStrRef charlist /* = k_HPHP_TRIM_CHARLIST */) {
|
||||
return StringUtil::Trim(str, StringUtil::TrimRight, charlist);
|
||||
return StringUtil::Trim(str, StringUtil::TrimType::Right, charlist);
|
||||
}
|
||||
Variant f_explode(CStrRef delimiter, CStrRef str, int limit /* = 0x7FFFFFFF */) {
|
||||
return StringUtil::Explode(str, delimiter, limit);
|
||||
|
||||
@@ -116,7 +116,7 @@ bool f_is_null(CVarRef v) {
|
||||
Variant f_print_r(CVarRef expression, bool ret /* = false */) {
|
||||
Variant res;
|
||||
try {
|
||||
VariableSerializer vs(VariableSerializer::PrintR);
|
||||
VariableSerializer vs(VariableSerializer::Type::PrintR);
|
||||
if (ret) {
|
||||
res = vs.serialize(expression, ret);
|
||||
} else {
|
||||
@@ -133,7 +133,7 @@ Variant f_print_r(CVarRef expression, bool ret /* = false */) {
|
||||
Variant f_var_export(CVarRef expression, bool ret /* = false */) {
|
||||
Variant res;
|
||||
try {
|
||||
VariableSerializer vs(VariableSerializer::VarExport);
|
||||
VariableSerializer vs(VariableSerializer::Type::VarExport);
|
||||
if (ret) {
|
||||
res = vs.serialize(expression, ret);
|
||||
} else {
|
||||
@@ -147,7 +147,7 @@ Variant f_var_export(CVarRef expression, bool ret /* = false */) {
|
||||
}
|
||||
|
||||
void f_var_dump(CVarRef v) {
|
||||
VariableSerializer vs(VariableSerializer::VarDump, 0, 2);
|
||||
VariableSerializer vs(VariableSerializer::Type::VarDump, 0, 2);
|
||||
// manipulate maxCount to match PHP behavior
|
||||
if (!v.isObject()) {
|
||||
vs.incMaxCount();
|
||||
@@ -164,7 +164,7 @@ void f_var_dump(int _argc, CVarRef expression,
|
||||
}
|
||||
|
||||
void f_debug_zval_dump(CVarRef variable) {
|
||||
VariableSerializer vs(VariableSerializer::DebugDump);
|
||||
VariableSerializer vs(VariableSerializer::Type::DebugDump);
|
||||
vs.serialize(variable, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -972,11 +972,11 @@ const Func* VMExecutionContext::lookupMethodCtx(const Class* cls,
|
||||
CallType callType,
|
||||
bool raise /* = false */) {
|
||||
const Func* method;
|
||||
if (callType == CtorMethod) {
|
||||
if (callType == CallType::CtorMethod) {
|
||||
assert(methodName == nullptr);
|
||||
method = cls->getCtor();
|
||||
} else {
|
||||
assert(callType == ObjMethod || callType == ClsMethod);
|
||||
assert(callType == CallType::ObjMethod || callType == CallType::ClsMethod);
|
||||
assert(methodName != nullptr);
|
||||
method = cls->lookupMethod(methodName);
|
||||
while (!method) {
|
||||
@@ -1065,7 +1065,7 @@ const Func* VMExecutionContext::lookupMethodCtx(const Class* cls,
|
||||
// of cls that declares a private method with this name AND the context
|
||||
// class is an ancestor of cls, check if the context class declares a
|
||||
// private method with this name.
|
||||
if (method->hasPrivateAncestor() && callType == ObjMethod &&
|
||||
if (method->hasPrivateAncestor() && callType == CallType::ObjMethod &&
|
||||
ctx && cls->classof(ctx)) {
|
||||
const Func* ctxMethod = ctx->lookupMethod(methodName);
|
||||
if (ctxMethod && ctxMethod->cls() == ctx &&
|
||||
@@ -1093,22 +1093,22 @@ LookupResult VMExecutionContext::lookupObjMethod(const Func*& f,
|
||||
const StringData* methodName,
|
||||
bool raise /* = false */) {
|
||||
Class* ctx = arGetContextClass(getFP());
|
||||
f = lookupMethodCtx(cls, methodName, ctx, ObjMethod, false);
|
||||
f = lookupMethodCtx(cls, methodName, ctx, CallType::ObjMethod, false);
|
||||
if (!f) {
|
||||
f = cls->lookupMethod(s___call.get());
|
||||
if (!f) {
|
||||
if (raise) {
|
||||
// Throw a fatal error
|
||||
lookupMethodCtx(cls, methodName, ctx, ObjMethod, true);
|
||||
lookupMethodCtx(cls, methodName, ctx, CallType::ObjMethod, true);
|
||||
}
|
||||
return MethodNotFound;
|
||||
return LookupResult::MethodNotFound;
|
||||
}
|
||||
return MagicCallFound;
|
||||
return LookupResult::MagicCallFound;
|
||||
}
|
||||
if (f->attrs() & AttrStatic && !f->isClosureBody()) {
|
||||
return MethodFoundNoThis;
|
||||
return LookupResult::MethodFoundNoThis;
|
||||
}
|
||||
return MethodFoundWithThis;
|
||||
return LookupResult::MethodFoundWithThis;
|
||||
}
|
||||
|
||||
LookupResult
|
||||
@@ -1119,7 +1119,7 @@ VMExecutionContext::lookupClsMethod(const Func*& f,
|
||||
ActRec* vmfp,
|
||||
bool raise /* = false */) {
|
||||
Class* ctx = arGetContextClass(vmfp);
|
||||
f = lookupMethodCtx(cls, methodName, ctx, ClsMethod, false);
|
||||
f = lookupMethodCtx(cls, methodName, ctx, CallType::ClsMethod, false);
|
||||
if (!f) {
|
||||
if (obj && obj->instanceof(cls)) {
|
||||
f = obj->getVMClass()->lookupMethod(s___call.get());
|
||||
@@ -1129,26 +1129,26 @@ VMExecutionContext::lookupClsMethod(const Func*& f,
|
||||
if (!f) {
|
||||
if (raise) {
|
||||
// Throw a fatal errpr
|
||||
lookupMethodCtx(cls, methodName, ctx, ClsMethod, true);
|
||||
lookupMethodCtx(cls, methodName, ctx, CallType::ClsMethod, true);
|
||||
}
|
||||
return MethodNotFound;
|
||||
return LookupResult::MethodNotFound;
|
||||
}
|
||||
f->validate();
|
||||
assert(f);
|
||||
assert(f->attrs() & AttrStatic);
|
||||
return MagicCallStaticFound;
|
||||
return LookupResult::MagicCallStaticFound;
|
||||
}
|
||||
assert(f);
|
||||
assert(obj);
|
||||
// __call cannot be static, this should be enforced by semantic
|
||||
// checks defClass time or earlier
|
||||
assert(!(f->attrs() & AttrStatic));
|
||||
return MagicCallFound;
|
||||
return LookupResult::MagicCallFound;
|
||||
}
|
||||
if (obj && !(f->attrs() & AttrStatic) && obj->instanceof(cls)) {
|
||||
return MethodFoundWithThis;
|
||||
return LookupResult::MethodFoundWithThis;
|
||||
}
|
||||
return MethodFoundNoThis;
|
||||
return LookupResult::MethodFoundNoThis;
|
||||
}
|
||||
|
||||
LookupResult VMExecutionContext::lookupCtorMethod(const Func*& f,
|
||||
@@ -1157,15 +1157,15 @@ LookupResult VMExecutionContext::lookupCtorMethod(const Func*& f,
|
||||
f = cls->getCtor();
|
||||
if (!(f->attrs() & AttrPublic)) {
|
||||
Class* ctx = arGetContextClass(getFP());
|
||||
f = lookupMethodCtx(cls, nullptr, ctx, CtorMethod, raise);
|
||||
f = lookupMethodCtx(cls, nullptr, ctx, CallType::CtorMethod, raise);
|
||||
if (!f) {
|
||||
// If raise was true than lookupMethodCtx should have thrown,
|
||||
// so we should only be able to get here if raise was false
|
||||
assert(!raise);
|
||||
return MethodNotFound;
|
||||
return LookupResult::MethodNotFound;
|
||||
}
|
||||
}
|
||||
return MethodFoundWithThis;
|
||||
return LookupResult::MethodFoundWithThis;
|
||||
}
|
||||
|
||||
ObjectData* VMExecutionContext::createObject(StringData* clsName,
|
||||
@@ -3052,7 +3052,7 @@ VMExecutionContext::getHelper(PC& pc,
|
||||
Variant& tvRef2,
|
||||
MemberCode& mcode,
|
||||
TypedValue*& curMember) {
|
||||
getHelperPre<true, true, ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
getHelperPre<true, true, VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
getHelperPost<true>(GETHELPERPOST_ARGS);
|
||||
}
|
||||
|
||||
@@ -3238,7 +3238,7 @@ inline bool OPTBLD_INLINE VMExecutionContext::memberHelperPre(
|
||||
curMember = (setMember && mcode == MW) ? nullptr : m_stack.indTV(depth--);
|
||||
}
|
||||
|
||||
if (mleave == LeaveLast) {
|
||||
if (mleave == VectorLeaveCode::LeaveLast) {
|
||||
if (vec >= pc) {
|
||||
assert(vec == pc);
|
||||
break;
|
||||
@@ -3287,7 +3287,7 @@ inline bool OPTBLD_INLINE VMExecutionContext::memberHelperPre(
|
||||
base = result;
|
||||
}
|
||||
|
||||
if (mleave == ConsumeAll) {
|
||||
if (mleave == VectorLeaveCode::ConsumeAll) {
|
||||
assert(vec == pc);
|
||||
if (debug) {
|
||||
if (lcode == LSC || lcode == LSL) {
|
||||
@@ -4525,7 +4525,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopVGetM(PC& pc) {
|
||||
TypedValue* tv1 = m_stack.allocTV();
|
||||
tvWriteUninit(tv1);
|
||||
if (!setHelperPre<false, true, false, true, 1,
|
||||
ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
if (base->m_type != KindOfRef) {
|
||||
tvBox(base);
|
||||
}
|
||||
@@ -4591,7 +4591,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopIssetS(PC& pc) {
|
||||
inline void OPTBLD_INLINE VMExecutionContext::iopIssetM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_GETHELPER_ARGS
|
||||
getHelperPre<false, false, LeaveLast>(MEMBERHELPERPRE_ARGS);
|
||||
getHelperPre<false, false, VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS);
|
||||
// Process last member specially, in order to employ the IssetElem/IssetProp
|
||||
// operations. (TODO combine with EmptyM.)
|
||||
bool issetResult = false;
|
||||
@@ -4721,7 +4721,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopEmptyS(PC& pc) {
|
||||
inline void OPTBLD_INLINE VMExecutionContext::iopEmptyM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_GETHELPER_ARGS
|
||||
getHelperPre<false, false, LeaveLast>(MEMBERHELPERPRE_ARGS);
|
||||
getHelperPre<false, false, VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS);
|
||||
// Process last member specially, in order to employ the EmptyElem/EmptyProp
|
||||
// operations. (TODO combine with IssetM)
|
||||
bool emptyResult = false;
|
||||
@@ -4836,7 +4836,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopSetM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_SETHELPER_ARGS
|
||||
if (!setHelperPre<false, true, false, false, 1,
|
||||
LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
Cell* c1 = m_stack.topC();
|
||||
|
||||
if (mcode == MW) {
|
||||
@@ -4873,7 +4873,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopSetWithRefLM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_SETHELPER_ARGS
|
||||
bool skip = setHelperPre<false, true, false, false, 0,
|
||||
ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
DECODE_HA(local);
|
||||
if (!skip) {
|
||||
TypedValue* from = frame_local(m_fp, local);
|
||||
@@ -4886,7 +4886,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopSetWithRefRM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_SETHELPER_ARGS
|
||||
bool skip = setHelperPre<false, true, false, false, 1,
|
||||
ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS);
|
||||
if (!skip) {
|
||||
TypedValue* from = m_stack.top();
|
||||
tvAsVariant(base) = withRefBind(tvAsVariant(from));
|
||||
@@ -4971,7 +4971,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopSetOpM(PC& pc) {
|
||||
DECODE(unsigned char, op);
|
||||
DECLARE_SETHELPER_ARGS
|
||||
if (!setHelperPre<MoreWarnings, true, false, false, 1,
|
||||
LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
TypedValue* result;
|
||||
Cell* rhs = m_stack.topC();
|
||||
|
||||
@@ -5064,7 +5064,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopIncDecM(PC& pc) {
|
||||
TypedValue to;
|
||||
tvWriteUninit(&to);
|
||||
if (!setHelperPre<MoreWarnings, true, false, false, 0,
|
||||
LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
if (mcode == MW) {
|
||||
IncDecNewElem<true>(tvScratch, *tvRef.asTypedValue(), op, base, to);
|
||||
} else {
|
||||
@@ -5156,7 +5156,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopBindM(PC& pc) {
|
||||
DECLARE_SETHELPER_ARGS
|
||||
TypedValue* tv1 = m_stack.topTV();
|
||||
if (!setHelperPre<false, true, false, true, 1,
|
||||
ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
// Bind the element/property with the var on the top of the stack
|
||||
tvBind(tv1, base);
|
||||
}
|
||||
@@ -5202,7 +5202,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopUnsetM(PC& pc) {
|
||||
NEXT();
|
||||
DECLARE_SETHELPER_ARGS
|
||||
if (!setHelperPre<false, false, true, false, 0,
|
||||
LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::LeaveLast>(MEMBERHELPERPRE_ARGS)) {
|
||||
switch (mcode) {
|
||||
case MEL:
|
||||
case MEC:
|
||||
@@ -5323,16 +5323,17 @@ void VMExecutionContext::fPushObjMethodImpl(
|
||||
ActRec* ar = m_stack.allocA();
|
||||
arSetSfp(ar, m_fp);
|
||||
ar->m_func = f;
|
||||
if (res == MethodFoundNoThis) {
|
||||
if (res == LookupResult::MethodFoundNoThis) {
|
||||
decRefObj(obj);
|
||||
ar->setClass(cls);
|
||||
} else {
|
||||
assert(res == MethodFoundWithThis || res == MagicCallFound);
|
||||
assert(res == LookupResult::MethodFoundWithThis ||
|
||||
res == LookupResult::MagicCallFound);
|
||||
/* Transfer ownership of obj to the ActRec*/
|
||||
ar->setThis(obj);
|
||||
}
|
||||
ar->initNumArgs(numArgs);
|
||||
if (res == MagicCallFound) {
|
||||
if (res == LookupResult::MagicCallFound) {
|
||||
ar->setInvName(name);
|
||||
} else {
|
||||
ar->setVarEnv(NULL);
|
||||
@@ -5381,11 +5382,13 @@ void VMExecutionContext::pushClsMethodImpl(Class* cls,
|
||||
int numArgs) {
|
||||
const Func* f;
|
||||
LookupResult res = lookupClsMethod(f, cls, name, obj, getFP(), true);
|
||||
if (res == MethodFoundNoThis || res == MagicCallStaticFound) {
|
||||
if (res == LookupResult::MethodFoundNoThis ||
|
||||
res == LookupResult::MagicCallStaticFound) {
|
||||
obj = nullptr;
|
||||
} else {
|
||||
assert(obj);
|
||||
assert(res == MethodFoundWithThis || res == MagicCallFound);
|
||||
assert(res == LookupResult::MethodFoundWithThis ||
|
||||
res == LookupResult::MagicCallFound);
|
||||
obj->incRefCount();
|
||||
}
|
||||
assert(f);
|
||||
@@ -5409,7 +5412,8 @@ void VMExecutionContext::pushClsMethodImpl(Class* cls,
|
||||
}
|
||||
}
|
||||
ar->initNumArgs(numArgs);
|
||||
if (res == MagicCallFound || res == MagicCallStaticFound) {
|
||||
if (res == LookupResult::MagicCallFound ||
|
||||
res == LookupResult::MagicCallStaticFound) {
|
||||
ar->setInvName(name);
|
||||
} else {
|
||||
ar->setVarEnv(nullptr);
|
||||
@@ -5480,7 +5484,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopFPushCtor(PC& pc) {
|
||||
// Lookup the ctor
|
||||
const Func* f;
|
||||
LookupResult res UNUSED = lookupCtorMethod(f, cls, true);
|
||||
assert(res == MethodFoundWithThis);
|
||||
assert(res == LookupResult::MethodFoundWithThis);
|
||||
// Replace input with uninitialized instance.
|
||||
ObjectData* this_ = newInstance(cls);
|
||||
TRACE(2, "FPushCtor: just new'ed an instance of class %s: %p\n",
|
||||
@@ -5513,7 +5517,7 @@ inline void OPTBLD_INLINE VMExecutionContext::iopFPushCtorD(PC& pc) {
|
||||
// Lookup the ctor
|
||||
const Func* f;
|
||||
LookupResult res UNUSED = lookupCtorMethod(f, cls, true);
|
||||
assert(res == MethodFoundWithThis);
|
||||
assert(res == LookupResult::MethodFoundWithThis);
|
||||
// Push uninitialized instance.
|
||||
ObjectData* this_ = newInstance(cls);
|
||||
TRACE(2, "FPushCtorD: new'ed an instance of class %s: %p\n",
|
||||
@@ -5797,7 +5801,7 @@ void VMExecutionContext::iopFPassM(PC& pc) {
|
||||
TypedValue* tv1 = m_stack.allocTV();
|
||||
tvWriteUninit(tv1);
|
||||
if (!setHelperPre<false, true, false, true, 1,
|
||||
ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
VectorLeaveCode::ConsumeAll>(MEMBERHELPERPRE_ARGS)) {
|
||||
if (base->m_type != KindOfRef) {
|
||||
tvBox(base);
|
||||
}
|
||||
|
||||
@@ -3372,7 +3372,7 @@ const Func* loadClassCtor(Class* cls) {
|
||||
VMRegAnchor _;
|
||||
UNUSED MethodLookup::LookupResult res =
|
||||
g_vmContext->lookupCtorMethod(f, cls, true /*raise*/);
|
||||
assert(res == MethodLookup::MethodFoundWithThis);
|
||||
assert(res == MethodLookup::LookupResult::MethodFoundWithThis);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -1895,8 +1895,8 @@ void HhbcTranslator::emitFPushObjMethodD(int32_t numParams,
|
||||
if (baseClass && !(baseClass->attrs() & AttrInterface)) {
|
||||
MethodLookup::LookupResult res =
|
||||
g_vmContext->lookupObjMethod(func, baseClass, methodName, false);
|
||||
if ((res == MethodLookup::MethodFoundWithThis ||
|
||||
res == MethodLookup::MethodFoundNoThis) &&
|
||||
if ((res == MethodLookup::LookupResult::MethodFoundWithThis ||
|
||||
res == MethodLookup::LookupResult::MethodFoundNoThis) &&
|
||||
!func->isAbstract()) {
|
||||
/*
|
||||
* If we found the func in baseClass, then either:
|
||||
@@ -1914,7 +1914,7 @@ void HhbcTranslator::emitFPushObjMethodD(int32_t numParams,
|
||||
SSATmp* funcTmp = gen(
|
||||
LdClsMethod, clsTmp, cns(func->methodSlot())
|
||||
);
|
||||
if (res == MethodLookup::MethodFoundNoThis) {
|
||||
if (res == MethodLookup::LookupResult::MethodFoundNoThis) {
|
||||
gen(DecRef, obj);
|
||||
objOrCls = clsTmp;
|
||||
}
|
||||
|
||||
@@ -485,15 +485,15 @@ void methodCacheSlowPath(MethodCache::Pair* mce,
|
||||
Class* ctx = arGetContextClass((ActRec*)ar->m_savedRbp);
|
||||
Stats::inc(Stats::TgtCache_MethodMiss);
|
||||
TRACE(2, "MethodCache: miss class %p name %s!\n", cls, name->data());
|
||||
func = g_vmContext->lookupMethodCtx(cls, name, ctx,
|
||||
MethodLookup::ObjMethod, false);
|
||||
auto const& objMethod = MethodLookup::CallType::ObjMethod;
|
||||
func = g_vmContext->lookupMethodCtx(cls, name, ctx, objMethod, false);
|
||||
if (UNLIKELY(!func)) {
|
||||
isMagicCall = true;
|
||||
func = cls->lookupMethod(s___call.get());
|
||||
if (UNLIKELY(!func)) {
|
||||
// Do it again, but raise the error this time.
|
||||
(void) g_vmContext->lookupMethodCtx(cls, name, ctx,
|
||||
MethodLookup::ObjMethod, true);
|
||||
(void) g_vmContext->lookupMethodCtx(cls, name, ctx, objMethod,
|
||||
true);
|
||||
NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
@@ -1030,7 +1030,7 @@ StaticMethodCache::lookupIR(Handle handle, const NamedEntity *ne,
|
||||
// in that case.
|
||||
(ActRec*)vmfp,
|
||||
false /*raise*/);
|
||||
if (LIKELY(res == MethodFoundNoThis &&
|
||||
if (LIKELY(res == LookupResult::MethodFoundNoThis &&
|
||||
!f->isAbstract() &&
|
||||
f->isStatic())) {
|
||||
f->validate();
|
||||
@@ -1042,7 +1042,7 @@ StaticMethodCache::lookupIR(Handle handle, const NamedEntity *ne,
|
||||
ar->setClass(const_cast<Class*>(cls));
|
||||
return f;
|
||||
}
|
||||
assert(res != MethodFoundWithThis); // Not possible: no this supplied.
|
||||
assert(res != LookupResult::MethodFoundWithThis); // Not possible: no this.
|
||||
|
||||
// Indicate to the IR that it should take even slower path
|
||||
return nullptr;
|
||||
@@ -1073,7 +1073,7 @@ StaticMethodCache::lookup(Handle handle, const NamedEntity *ne,
|
||||
// in that case.
|
||||
ec->getFP(),
|
||||
false /*raise*/);
|
||||
if (LIKELY(res == MethodFoundNoThis &&
|
||||
if (LIKELY(res == LookupResult::MethodFoundNoThis &&
|
||||
!f->isAbstract() &&
|
||||
f->isStatic())) {
|
||||
f->validate();
|
||||
@@ -1085,7 +1085,7 @@ StaticMethodCache::lookup(Handle handle, const NamedEntity *ne,
|
||||
ar->setClass(const_cast<Class*>(cls));
|
||||
return f;
|
||||
}
|
||||
assert(res != MethodFoundWithThis); // Not possible: no this supplied.
|
||||
assert(res != LookupResult::MethodFoundWithThis); // Not possible: no this.
|
||||
// We've already sync'ed regs; this is some hard case, we might as well
|
||||
// just let the interpreter handle this entirely.
|
||||
assert(*vmpc() == OpFPushClsMethodD);
|
||||
@@ -1118,8 +1118,8 @@ StaticMethodFCache::lookupIR(Handle handle, const Class* cls,
|
||||
nullptr,
|
||||
(ActRec*)vmfp,
|
||||
false /*raise*/);
|
||||
assert(res != MethodFoundWithThis); // Not possible: no this supplied.
|
||||
if (LIKELY(res == MethodFoundNoThis && !f->isAbstract())) {
|
||||
assert(res != LookupResult::MethodFoundWithThis); // Not possible: no this.
|
||||
if (LIKELY(res == LookupResult::MethodFoundNoThis && !f->isAbstract())) {
|
||||
// We called lookupClsMethod with a NULL this and got back a
|
||||
// method that may or may not be static. This implies that
|
||||
// lookupClsMethod, given the same class and the same method name,
|
||||
|
||||
@@ -2892,7 +2892,7 @@ newInstanceHelper(Class* cls, int numArgs, ActRec* ar, ActRec* prevAr) {
|
||||
VMRegAnchor _;
|
||||
UNUSED MethodLookup::LookupResult res =
|
||||
g_vmContext->lookupCtorMethod(f, cls, true /*raise*/);
|
||||
assert(res == MethodLookup::MethodFoundWithThis);
|
||||
assert(res == MethodLookup::LookupResult::MethodFoundWithThis);
|
||||
}
|
||||
// Don't start pushing the AR until newInstance returns; it may reenter.
|
||||
ret = newInstance(cls);
|
||||
|
||||
@@ -4150,17 +4150,17 @@ const Func* lookupImmutableMethod(const Class* cls, const StringData* name,
|
||||
g_vmContext->getFP(), false) :
|
||||
g_vmContext->lookupObjMethod(func, cls, name, false);
|
||||
|
||||
if (res == MethodLookup::MethodNotFound) return nullptr;
|
||||
if (res == MethodLookup::LookupResult::MethodNotFound) return nullptr;
|
||||
|
||||
assert(res == MethodLookup::MethodFoundWithThis ||
|
||||
res == MethodLookup::MethodFoundNoThis ||
|
||||
assert(res == MethodLookup::LookupResult::MethodFoundWithThis ||
|
||||
res == MethodLookup::LookupResult::MethodFoundNoThis ||
|
||||
(staticLookup ?
|
||||
res == MethodLookup::MagicCallStaticFound :
|
||||
res == MethodLookup::MagicCallFound));
|
||||
res == MethodLookup::LookupResult::MagicCallStaticFound :
|
||||
res == MethodLookup::LookupResult::MagicCallFound));
|
||||
|
||||
magicCall =
|
||||
res == MethodLookup::MagicCallStaticFound ||
|
||||
res == MethodLookup::MagicCallFound;
|
||||
res == MethodLookup::LookupResult::MagicCallStaticFound ||
|
||||
res == MethodLookup::LookupResult::MagicCallFound;
|
||||
|
||||
if ((privateOnly && (!(func->attrs() & AttrPrivate) || magicCall)) ||
|
||||
func->isAbstract() ||
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
virtual void handleRequest(Transport *transport) {
|
||||
transport->addHeader("ECHOED", transport->getHeader("ECHO").c_str());
|
||||
|
||||
if (transport->getMethod() == Transport::POST) {
|
||||
if (transport->getMethod() == Transport::Method::POST) {
|
||||
int len = 0;
|
||||
const void *data = transport->getPostData(len);
|
||||
String res = "POST: ";
|
||||
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
virtual const char *getRemoteHost() { return "remote";}
|
||||
virtual const void *getPostData(int &size) { size = 0; return nullptr;}
|
||||
virtual uint16_t getRemotePort() { return 0; }
|
||||
virtual Method getMethod() { return Transport::GET;}
|
||||
virtual Method getMethod() { return Transport::Method::GET;}
|
||||
virtual std::string getHeader(const char *name) { return "";}
|
||||
virtual void getHeaders(HeaderMap &headers) {}
|
||||
virtual void addHeaderImpl(const char *name, const char *value) {}
|
||||
@@ -539,7 +539,7 @@ public:
|
||||
response = "\nGET param: name = ";
|
||||
response += transport->getParam("name");
|
||||
|
||||
if (transport->getMethod() == Transport::POST) {
|
||||
if (transport->getMethod() == Transport::Method::POST) {
|
||||
int size = 0;
|
||||
const char *data = (const char *)transport->getPostData(size);
|
||||
response += "\nPOST data: ";
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário