本文整理汇总了C++中ArrayIter::secondRef方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayIter::secondRef方法的具体用法?C++ ArrayIter::secondRef怎么用?C++ ArrayIter::secondRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayIter
的用法示例。
在下文中一共展示了ArrayIter::secondRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _readline_command_generator
/* This function is called repeatedly by rl_completion_matches. The first
* invocation has state = 0, subsequent ones have state != 0. A return value of
* nullptr indicates that all possible completions have been returned. */
static char* _readline_command_generator(const char* text, int state) {
static ArrayIter iter;
if (state == 0) {
iter = s_readline->array.begin();
}
auto text_str = String(text);
while (iter) {
auto value = iter.secondRef().toString();
++iter;
if (text_str == value.substr(0, text_str.length())) {
// readline frees this using free(), so we must use malloc() and not new
return strdup(value.data());
}
}
return nullptr;
}
示例2: Load
bool BuiltinSymbols::Load(AnalysisResultPtr ar, bool extOnly /* = false */) {
if (Loaded) return true;
Loaded = true;
// load extension functions first, so system/classes may call them
ParseExtFunctions(ar, ExtensionFunctions, false);
AnalysisResultPtr ar2 = AnalysisResultPtr(new AnalysisResult());
s_variables = VariableTablePtr(new VariableTable(*ar2.get()));
s_constants = ConstantTablePtr(new ConstantTable(*ar2.get()));
// parse all PHP files under system/classes
if (!extOnly) {
ar = AnalysisResultPtr(new AnalysisResult());
ar->loadBuiltinFunctions();
string slib = systemlib_path();
if (slib.empty()) {
for (const char **cls = SystemClasses; *cls; cls++) {
string phpBaseName = "/system/classes/";
phpBaseName += *cls;
phpBaseName += ".php";
Parse(ar, phpBaseName, Option::GetSystemRoot() + phpBaseName);
}
} else {
Parse(ar, slib, slib);
}
ar->analyzeProgram(true);
ar->inferTypes();
const StringToFileScopePtrMap &files = ar->getAllFiles();
for (StringToFileScopePtrMap::const_iterator iterFile = files.begin();
iterFile != files.end(); iterFile++) {
const StringToClassScopePtrVecMap &classes =
iterFile->second->getClasses();
for (StringToClassScopePtrVecMap::const_iterator iter = classes.begin();
iter != classes.end(); ++iter) {
assert(iter->second.size() == 1);
iter->second[0]->setSystem();
assert(!s_classes[iter->first]);
s_classes[iter->first] = iter->second[0];
}
}
} else {
NoSuperGlobals = true;
}
// load extension constants, classes and dynamics
ParseExtConsts(ar, ExtensionConsts, false);
ParseExtClasses(ar, ExtensionClasses, false);
for (unsigned int i = 0; i < Option::SepExtensions.size(); i++) {
Option::SepExtensionOptions &options = Option::SepExtensions[i];
string soname = options.soname;
if (soname.empty()) {
soname = string("lib") + options.name + ".so";
}
if (!options.lib_path.empty()) {
soname = options.lib_path + "/" + soname;
}
if (!LoadSepExtensionSymbols(ar, options.name, soname)) {
return false;
}
}
if (!extOnly) {
Array constants = ClassInfo::GetSystemConstants();
LocationPtr loc(new Location);
for (ArrayIter it = constants.begin(); it; ++it) {
CVarRef key = it.first();
if (!key.isString()) continue;
std::string name = key.toCStrRef().data();
if (s_constants->getSymbol(name)) continue;
if (name == "true" || name == "false" || name == "null") continue;
CVarRef value = it.secondRef();
if (!value.isInitialized() || value.isObject()) continue;
ExpressionPtr e = Expression::MakeScalarExpression(ar2, ar2, loc, value);
TypePtr t =
value.isNull() ? Type::Null :
value.isBoolean() ? Type::Boolean :
value.isInteger() ? Type::Int64 :
value.isDouble() ? Type::Double :
value.isArray() ? Type::Array : Type::Variant;
s_constants->add(key.toCStrRef().data(), t, e, ar2, e);
}
s_variables = ar2->getVariables();
for (int i = 0, n = NumGlobalNames(); i < n; ++i) {
s_variables->add(GlobalNames[i], Type::Variant, false, ar,
ConstructPtr(), ModifierExpressionPtr());
}
}
s_constants->setDynamic(ar, "SID", true);
return true;
}
示例3: Load
bool BuiltinSymbols::Load(AnalysisResultPtr ar) {
if (Loaded) return true;
Loaded = true;
if (g_context.isNull()) init_thread_locals();
ClassInfo::Load();
// load extension functions first, so system/php may call them
ImportExtFunctions(ar, ClassInfo::GetSystem());
ConstantTablePtr cns = ar->getConstants();
// load extension constants, classes and dynamics
ImportNativeConstants(ar, cns);
ImportExtConstants(ar, cns, ClassInfo::GetSystem());
ImportExtClasses(ar);
Array constants = ClassInfo::GetSystemConstants();
LocationPtr loc(new Location);
for (ArrayIter it = constants.begin(); it; ++it) {
CVarRef key = it.first();
if (!key.isString()) continue;
std::string name = key.toCStrRef().data();
if (cns->getSymbol(name)) continue;
if (name == "true" || name == "false" || name == "null") continue;
CVarRef value = it.secondRef();
if (!value.isInitialized() || value.isObject()) continue;
ExpressionPtr e = Expression::MakeScalarExpression(ar, ar, loc, value);
TypePtr t =
value.isNull() ? Type::Null :
value.isBoolean() ? Type::Boolean :
value.isInteger() ? Type::Int64 :
value.isDouble() ? Type::Double :
value.isArray() ? Type::Array : Type::Variant;
cns->add(key.toCStrRef().data(), t, e, ar, e);
}
for (int i = 0, n = NumGlobalNames(); i < n; ++i) {
ar->getVariables()->add(GlobalNames[i], Type::Variant, false, ar,
ConstructPtr(), ModifierExpressionPtr());
}
cns->setDynamic(ar, "PHP_BINARY", true);
cns->setDynamic(ar, "PHP_BINDIR", true);
cns->setDynamic(ar, "PHP_OS", true);
cns->setDynamic(ar, "PHP_SAPI", true);
cns->setDynamic(ar, "SID", true);
// Systemlib files were all parsed by hphp_process_init
const StringToFileScopePtrMap &files = ar->getAllFiles();
for (const auto& file : files) {
file.second->setSystem();
const auto& classes = file.second->getClasses();
for (const auto& clsVec : classes) {
assert(clsVec.second.size() == 1);
auto cls = clsVec.second[0];
cls->setSystem();
ar->addSystemClass(cls);
for (const auto& func : cls->getFunctions()) {
FunctionScope::RecordFunctionInfo(func.first, func.second);
}
}
const auto& functions = file.second->getFunctions();
for (const auto& func : functions) {
func.second->setSystem();
ar->addSystemFunction(func.second);
FunctionScope::RecordFunctionInfo(func.first, func.second);
}
}
return true;
}
示例4: recursiveAddVarImpl
bool WddxPacket::recursiveAddVarImpl(const String& varName,
const Variant& varVariant,
bool hasVarTag,
SeenContainers& seen) {
bool isArray = varVariant.isArray();
bool isObject = varVariant.isObject();
if (isArray || isObject) {
Array varAsArray;
Object varAsObject;
ArrayOrObject ptr;
if (isArray) {
varAsArray = varVariant.toArray();
ptr = varAsArray.get();
}
if (isObject) {
varAsObject = varVariant.toObject();
varAsArray = varAsObject.toArray();
ptr = varAsObject.get();
}
assert(!ptr.isNull());
if (!seen.emplace(ptr).second) {
raise_warning("recursion detected");
return false;
}
SCOPE_EXIT { seen.erase(ptr); };
if (hasVarTag) {
m_packetString.append("<var name='");
m_packetString.append(varName.data());
m_packetString.append("'>");
}
int length = varAsArray.length();
if (length > 0) {
ArrayIter it = ArrayIter(varAsArray);
if (it.first().isString()) isObject = true;
if (isObject) {
m_packetString.append("<struct>");
if (!isArray) {
m_packetString.append("<var name='php_class_name'><string>");
m_packetString.append(varAsObject->getClassName());
m_packetString.append("</string></var>");
}
} else {
m_packetString.append("<array length='");
m_packetString.append(std::to_string(length));
m_packetString.append("'>");
}
for (; it; ++it) {
auto key = it.first();
auto const& value = it.secondRef();
recursiveAddVarImpl(key.toString(), value, isObject, seen);
}
if (isObject) {
m_packetString.append("</struct>");
}
else {
m_packetString.append("</array>");
}
}
else {
//empty object
if (isObject) {
m_packetString.append("<struct>");
if (!isArray) {
m_packetString.append("<var name='php_class_name'><string>");
m_packetString.append(varAsObject->getClassName());
m_packetString.append("</string></var>");
}
m_packetString.append("</struct>");
}
}
if (hasVarTag) {
m_packetString.append("</var>");
}
return true;
}
示例5: Load
bool BuiltinSymbols::Load(AnalysisResultPtr ar, bool extOnly /* = false */) {
if (Loaded) return true;
Loaded = true;
if (g_context.isNull()) init_thread_locals();
ClassInfo::Load();
// load extension functions first, so system/classes may call them
ImportExtFunctions(ar, s_functions, ClassInfo::GetSystem());
AnalysisResultPtr ar2 = AnalysisResultPtr(new AnalysisResult());
s_variables = VariableTablePtr(new VariableTable(*ar2.get()));
s_constants = ConstantTablePtr(new ConstantTable(*ar2.get()));
// parse all PHP files under system/classes
if (!extOnly) {
ar = AnalysisResultPtr(new AnalysisResult());
ar->loadBuiltinFunctions();
string slib = get_systemlib();
Scanner scanner(slib.c_str(), slib.size(),
Option::ScannerType, "systemlib.php");
Compiler::Parser parser(scanner, "systemlib.php", ar);
if (!parser.parse()) {
Logger::Error("Unable to parse systemlib.php: %s",
parser.getMessage().c_str());
assert(false);
}
ar->analyzeProgram(true);
ar->inferTypes();
const StringToFileScopePtrMap &files = ar->getAllFiles();
for (StringToFileScopePtrMap::const_iterator iterFile = files.begin();
iterFile != files.end(); iterFile++) {
const StringToClassScopePtrVecMap &classes =
iterFile->second->getClasses();
for (StringToClassScopePtrVecMap::const_iterator iter = classes.begin();
iter != classes.end(); ++iter) {
assert(iter->second.size() == 1);
iter->second[0]->setSystem();
assert(!s_classes[iter->first]);
s_classes[iter->first] = iter->second[0];
}
}
} else {
NoSuperGlobals = true;
}
// load extension constants, classes and dynamics
ImportExtConstants(ar, s_constants, ClassInfo::GetSystem());
ImportExtClasses(ar);
if (!extOnly) {
Array constants = ClassInfo::GetSystemConstants();
LocationPtr loc(new Location);
for (ArrayIter it = constants.begin(); it; ++it) {
CVarRef key = it.first();
if (!key.isString()) continue;
std::string name = key.toCStrRef().data();
if (s_constants->getSymbol(name)) continue;
if (name == "true" || name == "false" || name == "null") continue;
CVarRef value = it.secondRef();
if (!value.isInitialized() || value.isObject()) continue;
ExpressionPtr e = Expression::MakeScalarExpression(ar2, ar2, loc, value);
TypePtr t =
value.isNull() ? Type::Null :
value.isBoolean() ? Type::Boolean :
value.isInteger() ? Type::Int64 :
value.isDouble() ? Type::Double :
value.isArray() ? Type::Array : Type::Variant;
s_constants->add(key.toCStrRef().data(), t, e, ar2, e);
}
s_variables = ar2->getVariables();
for (int i = 0, n = NumGlobalNames(); i < n; ++i) {
s_variables->add(GlobalNames[i], Type::Variant, false, ar,
ConstructPtr(), ModifierExpressionPtr());
}
}
s_constants->setDynamic(ar, "SID", true);
return true;
}