本文整理汇总了C++中StaticString::get方法的典型用法代码示例。如果您正苦于以下问题:C++ StaticString::get方法的具体用法?C++ StaticString::get怎么用?C++ StaticString::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StaticString
的用法示例。
在下文中一共展示了StaticString::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moduleInit
void moduleInit() override {
HHVM_ME(MCRouter, __construct);
HHVM_NAMED_ME(MCRouter, get, mcr_str<mc_op_get>);
HHVM_NAMED_ME(MCRouter, add, mcr_set<mc_op_add>);
HHVM_NAMED_ME(MCRouter, set, mcr_set<mc_op_set>);
HHVM_NAMED_ME(MCRouter, replace, mcr_set<mc_op_replace>);
HHVM_NAMED_ME(MCRouter, prepend, mcr_aprepend<mc_op_prepend>);
HHVM_NAMED_ME(MCRouter, append, mcr_aprepend<mc_op_append>);
HHVM_NAMED_ME(MCRouter, incr, mcr_str_delta<mc_op_incr>);
HHVM_NAMED_ME(MCRouter, decr, mcr_str_delta<mc_op_decr>);
HHVM_NAMED_ME(MCRouter, del, mcr_str<mc_op_delete>);
HHVM_NAMED_ME(MCRouter, flushAll, mcr_int<mc_op_flushall>);
HHVM_NAMED_ME(MCRouter, version, mcr_void<mc_op_version>);
Native::registerNativeDataInfo<MCRouter>(s_MCRouter.get());
HHVM_STATIC_ME(MCRouter, getOpName);
HHVM_STATIC_ME(MCRouter, getResultName);
std::string opname("mc_op_");
for (int i = 0; i < mc_nops; ++i) {
std::string name;
name = opname + mc_op_to_string((mc_op_t)i);
// mcrouter defines op names as foo-bar,
// but PHP wants constants like foo_bar
for (int j = opname.size(); j < name.size(); ++j) {
if (name[j] == '-') {
name[j] = '_';
}
}
Native::registerClassConstant<KindOfInt64>(
s_MCRouter.get(),
makeStaticString(name),
i);
}
for (int i = 0; i < mc_nres; ++i) {
Native::registerClassConstant<KindOfInt64>(
s_MCRouter.get(),
makeStaticString(mc_res_to_string((mc_res_t)i)),
i);
}
loadSystemlib();
}
示例2: MethInvokerFewArgs
Variant MethodStatement::MethInvokerFewArgs(MethodCallPackage &mcp,
int count, INVOKE_FEW_ARGS_IMPL_ARGS) {
const MethodStatementWrapper *msw = (const MethodStatementWrapper*)mcp.extra;
const MethodStatement *ms = msw->m_methodStatement;
bool check = !ms->m_name->isame(s___invoke.get());
bool isStatic = ms->getModifiers() & ClassStatement::Static;
if (isStatic || !mcp.obj) {
String cn;
if (UNLIKELY(!isStatic && mcp.isObj && mcp.obj == NULL)) {
// this is needed for continuations where
// we are passed the dummy object
cn = ms->getClass()->name();
} else {
cn = mcp.getClassName();
}
if (ms->refReturn()) {
return strongBind(ms->invokeStaticFewArgs(cn, count,
INVOKE_FEW_ARGS_PASS_ARGS, msw, check));
} else {
return ms->invokeStaticFewArgs(cn, count,
INVOKE_FEW_ARGS_PASS_ARGS, msw, check);
}
} else {
if (ms->refReturn()) {
return strongBind(ms->invokeInstanceFewArgs(mcp.rootObj, count,
INVOKE_FEW_ARGS_PASS_ARGS, msw, check));
} else {
return ms->invokeInstanceFewArgs(mcp.rootObj, count,
INVOKE_FEW_ARGS_PASS_ARGS, msw, check);
}
}
}
示例3: mcr_getOptionException
static Object mcr_getOptionException(
const std::vector<mc::McrouterOptionError>& errors) {
if (!c_MCRouterOptionException) {
c_MCRouterOptionException =
Unit::lookupClass(s_MCRouterOptionException.get());
assert(c_MCRouterOptionException);
}
Array errorArray = Array::Create();
for (auto err : errors) {
Array e;
e.set(s_option, String(err.requestedName));
e.set(s_value, String(err.requestedValue));
e.set(s_error, String(err.errorMsg));
errorArray.append(e);
}
auto objdata = ObjectData::newInstance(c_MCRouterOptionException);
Object obj(objdata);
TypedValue ret;
g_context->invokeFunc(
&ret,
c_MCRouterOptionException->getCtor(),
make_packed_array(errorArray),
objdata);
return obj;
}
示例4: callStat
Variant callStat(const String& path) {
static Func* f = SystemLib::s_PharClass->lookupMethod(s_stat.get());
return Variant::attach(
g_context->invokeFunc(f, make_packed_array(path), nullptr,
SystemLib::s_PharClass)
);
}
示例5: ai
BucketBrigade::BucketBrigade(const String& data) {
PackedArrayInit ai(2);
ai.append(data);
ai.append(data.length());
auto bucket = g_context->createObject(s_bucket_class.get(), ai.toArray());
appendBucket(Object::attach(bucket));
}
示例6: tvCastToStringInPlace
void tvCastToStringInPlace(TypedValue* tv) {
assert(tvIsPlausible(*tv));
tvUnboxIfNeeded(tv);
StringData* s;
do {
switch (tv->m_type) {
case KindOfUninit:
case KindOfNull:
s = staticEmptyString();
goto static_string;
case KindOfBoolean:
s = tv->m_data.num ? s_1.get() : staticEmptyString();
goto static_string;
case KindOfInt64:
s = buildStringData(tv->m_data.num);
continue;
case KindOfDouble:
s = buildStringData(tv->m_data.dbl);
continue;
case KindOfStaticString:
case KindOfString:
return;
case KindOfArray:
raise_notice("Array to string conversion");
s = array_string.get();
tvDecRefArr(tv);
goto static_string;
case KindOfObject:
// For objects, we fall back on the Variant machinery
tvAsVariant(tv) = tv->m_data.pobj->invokeToString();
return;
case KindOfResource:
// For resources, we fall back on the Variant machinery
tvAsVariant(tv) = tv->m_data.pres->o_toString();
return;
case KindOfRef:
case KindOfClass:
break;
}
not_reached();
} while (0);
s->incRefCount();
tv->m_data.pstr = s;
tv->m_type = KindOfString;
return;
static_string:
tv->m_data.pstr = s;
tv->m_type = KindOfStaticString;
}
示例7: tvCastToString
StringData* tvCastToString(const TypedValue* tv) {
assert(tvIsPlausible(*tv));
if (tv->m_type == KindOfRef) {
tv = tv->m_data.pref->tv();
}
StringData* s;
switch (tv->m_type) {
case KindOfUninit:
case KindOfNull: return staticEmptyString();
case KindOfBoolean: return tv->m_data.num ? s_1.get() : staticEmptyString();
case KindOfInt64: s = buildStringData(tv->m_data.num); break;
case KindOfDouble: s = buildStringData(tv->m_data.dbl); break;
case KindOfStaticString: return tv->m_data.pstr;
case KindOfString: s = tv->m_data.pstr; break;
case KindOfArray: raise_notice("Array to string conversion");
return array_string.get();
case KindOfObject: return tv->m_data.pobj->invokeToString().detach();
case KindOfResource: return tv->m_data.pres->o_toString().detach();
default: not_reached();
}
s->incRefCount();
return s;
}
示例8: chainFaultObjects
void chainFaultObjects(ObjectData* top, ObjectData* prev) {
while (true) {
auto const lookup = top->getProp(
top->instanceof(SystemLib::s_ExceptionClass)
? SystemLib::s_ExceptionClass
: SystemLib::s_ErrorClass,
s_previous.get()
);
auto const top_tv = lookup.prop;
assert(top_tv != nullptr);
assert(top_tv->m_type != KindOfUninit && lookup.accessible);
if (top_tv->m_type != KindOfObject ||
!top_tv->m_data.pobj->instanceof(SystemLib::s_ThrowableClass)) {
// Since we are overwriting, decref.
tvRefcountedDecRef(top_tv);
// Objects held in m_faults are not refcounted, therefore we need to
// increase the ref count here.
top_tv->m_type = KindOfObject;
top_tv->m_data.pobj = prev;
prev->incRefCount();
break;
}
top = top_tv->m_data.pobj;
}
}
示例9: mcr_throwOptionException
[[noreturn]]
static void mcr_throwOptionException(
const std::vector<mc::McrouterOptionError>& errors) {
if (!c_MCRouterOptionException) {
c_MCRouterOptionException =
Unit::lookupClass(s_MCRouterOptionException.get());
assert(c_MCRouterOptionException);
}
Array errorArray = Array::Create();
for (auto err : errors) {
Array e;
e.set(s_option, String(err.requestedName));
e.set(s_value, String(err.requestedValue));
e.set(s_error, String(err.errorMsg));
errorArray.append(e);
}
Object obj{c_MCRouterOptionException};
TypedValue ret;
g_context->invokeFunc(
&ret,
c_MCRouterOptionException->getCtor(),
make_packed_array(errorArray),
obj.get());
throw_object(obj);
}
示例10: objOffsetIsset
bool objOffsetIsset(TypedValue& tvRef, ObjectData* base, const Variant& offset,
bool validate /* = true */) {
auto exists = objOffsetExists(base, offset);
// Unless we called ArrayObject::offsetExists, there's nothing more to do
if (exists != OffsetExistsResult::IssetIfNonNull) {
return (int)exists;
}
// For ArrayObject::offsetExists, we need to check the value at `offset`.
// If it's null, then we return false.
TypedValue tvResult;
tvWriteUninit(&tvResult);
// We can't call the offsetGet method on `base` because users aren't
// expecting offsetGet to be called for `isset(...)` expressions, so call
// the method on the base ArrayObject class.
auto const method =
SystemLib::s_ArrayObjectClass->lookupMethod(s_offsetGet.get());
assert(method != nullptr);
g_context->invokeFuncFew(&tvResult, method, base, nullptr, 1,
offset.asCell());
auto const result = !IS_NULL_TYPE(tvResult.m_type);
tvRefcountedDecRef(&tvResult);
return result;
}
示例11: init
void c_Closure::init(int numArgs, ActRec* ar, TypedValue* sp) {
auto const invokeFunc = getVMClass()->lookupMethod(s_uuinvoke.get());
m_thisOrClass = ar->m_this;
if (ar->hasThis()) {
if (invokeFunc->attrs() & AttrStatic) {
// Only set the class for static closures.
m_thisOrClass = reinterpret_cast<ObjectData*>(
reinterpret_cast<intptr_t>(ar->getThis()->getVMClass()) | 1LL
);
} else {
ar->getThis()->incRefCount();
}
}
// Change my __invoke's m_cls to be the same as my creator's
Class* scope = ar->m_func->cls();
m_func = invokeFunc->cloneAndSetClass(scope);
// copy the props to instance variables
assert(m_cls->numDeclProperties() == numArgs);
TypedValue* beforeCurUseVar = sp + numArgs;
TypedValue* curProperty = propVec();
for (int i = 0; i < numArgs; i++) {
// teleport the references in here so we don't incref
tvCopy(*--beforeCurUseVar, *curProperty++);
}
}
示例12: init
void c_Closure::init(int numArgs, ActRec* ar, TypedValue* sp) {
auto const invokeFunc = getVMClass()->lookupMethod(s_uuinvoke.get());
m_ctx = ar->m_this;
if (ar->hasThis()) {
if (invokeFunc->isStatic()) {
// Only set the class for static closures.
setClass(ar->getThis()->getVMClass());
} else {
ar->getThis()->incRefCount();
}
}
/*
* Copy the use vars to instance variables, and initialize any
* instance properties that are for static locals to KindOfUninit.
*/
auto const numDeclProperties = getVMClass()->numDeclProperties();
assert(numDeclProperties - numArgs == getInvokeFunc()->numStaticLocals());
TypedValue* beforeCurUseVar = sp + numArgs;
TypedValue* curProperty = propVec();
int i = 0;
assert(numArgs <= numDeclProperties);
for (; i < numArgs; i++) {
// teleport the references in here so we don't incref
tvCopy(*--beforeCurUseVar, *curProperty++);
}
for (; i < numDeclProperties; ++i) {
tvWriteUninit(curProperty++);
}
}
示例13: copyContinuationVars
void c_Continuation::copyContinuationVars(ActRec* fp) {
// For functions that contain only named locals, we can copy TVs
// right to the local space.
static const StringData* thisStr = s_this.get();
bool skipThis;
if (fp->hasVarEnv()) {
Stats::inc(Stats::Cont_CreateVerySlow);
Array definedVariables = fp->getVarEnv()->getDefinedVariables();
skipThis = definedVariables.exists(s_this, true);
for (ArrayIter iter(definedVariables); !iter.end(); iter.next()) {
dupContVar(iter.first().getStringData(),
const_cast<TypedValue *>(iter.secondRef().asTypedValue()));
}
} else {
const Func *genFunc = actRec()->m_func;
skipThis = genFunc->lookupVarId(thisStr) != kInvalidId;
for (Id i = 0; i < genFunc->numNamedLocals(); ++i) {
dupContVar(genFunc->localVarName(i), frame_local(fp, i));
}
}
// If $this is used as a local inside the body and is not provided
// by our containing environment, just prefill it here instead of
// using InitThisLoc inside the body
if (!skipThis && fp->hasThis()) {
Id id = actRec()->m_func->lookupVarId(thisStr);
if (id != kInvalidId) {
tvAsVariant(frame_local(actRec(), id)) = fp->getThis();
}
}
}
示例14: hippo_mongo_driver_server_create_from_id
Object hippo_mongo_driver_server_create_from_id(mongoc_client_t *client, uint32_t server_id)
{
static Class* c_server;
mongoc_server_description_t *sd;
bson_error_t error;
c_server = Unit::lookupClass(s_MongoDriverServer_className.get());
Object tmp = Object{c_server};
sd = mongoc_topology_description_server_by_id(&client->topology->description, server_id, &error);
if (!sd) {
throw MongoDriver::Utils::CreateAndConstruct(
MongoDriver::s_MongoDriverExceptionRuntimeException_className,
"Failed to get server description, server likely gone: " + HPHP::Variant(error.message).toString(),
HPHP::Variant((uint64_t) 0)
);
}
tmp->o_set(s_MongoDriverServer___serverId, sd->host.host_and_port, s_MongoDriverServer_className);
MongoDBDriverServerData* result_data = Native::data<MongoDBDriverServerData>(tmp);
result_data->m_client = client;
result_data->m_server_id = server_id;
return tmp;
}
示例15: checkTypeAliasObj
bool TypeConstraint::checkTypeAliasObj(const Class* cls) const {
assert(isObject() && m_namedEntity && m_typeName);
// Look up the type alias (autoloading if necessary)
// and fail if we can't find it
auto const td = getTypeAliasWithAutoload(m_namedEntity, m_typeName);
if (!td) {
return false;
}
// We found the type alias, check if an object of type cls
// is compatible
switch (getAnnotMetaType(td->type)) {
case AnnotMetaType::Precise:
return td->type == AnnotType::Object && td->klass &&
cls->classof(td->klass);
case AnnotMetaType::Mixed:
return true;
case AnnotMetaType::Callable:
return cls->lookupMethod(s___invoke.get()) != nullptr;
case AnnotMetaType::Self:
case AnnotMetaType::Parent:
case AnnotMetaType::Number:
case AnnotMetaType::ArrayKey:
case AnnotMetaType::Dict:
case AnnotMetaType::Vec:
// Self and Parent should never happen, because type
// aliases are not allowed to use those MetaTypes
return false;
}
not_reached();
}