本文整理汇总了C++中ModulePtr::definitionContext方法的典型用法代码示例。如果您正苦于以下问题:C++ ModulePtr::definitionContext方法的具体用法?C++ ModulePtr::definitionContext怎么用?C++ ModulePtr::definitionContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModulePtr
的用法示例。
在下文中一共展示了ModulePtr::definitionContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modulePrefix
void
Slice::ObjCGenerator::MetaDataVisitor::modulePrefixError(const ModulePtr& m, const string& metadata)
{
string file = m->definitionContext()->filename();
string line = m->line();
ModulePrefix mp = modulePrefix(m);
string old_file = mp.m->definitionContext()->filename();
string old_line = mp.m->line();
ostringstream os;
if(!metadata.empty())
{
os << _msg << " `" << metadata << "': ";
}
os << "inconsistent module prefix previously defined ";
if(old_file != file)
{
os << "in " << old_file << ":";
}
else
{
os << "at line ";
}
os << line;
os << " as `" << mp.name << "'" << endl;
m->definitionContext()->warning(All, file, line, os.str());
}
示例2: getMetaData
void
Slice::ObjCGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
{
ModulePtr m = ModulePtr::dynamicCast(cont);
if(m)
{
bool error = false;
bool foundPrefix = false;
StringList meta = getMetaData(m);
StringList::const_iterator p;
for(p = meta.begin(); p != meta.end(); ++p)
{
const string prefix = "prefix:";
string name;
if(p->substr(_objcPrefix.size(), prefix.size()) == prefix)
{
foundPrefix = true;
name = trim(p->substr(_objcPrefix.size() + prefix.size()));
if(name.empty())
{
if(_history.count(*p) == 0)
{
string file = m->definitionContext()->filename();
ostringstream os;
os << _msg << " `" << *p << "'" << endl;
emitWarning(file, m->line(), os.str());
_history.insert(*p);
}
error = true;
}
else
{
if(!addModule(m, name))
{
modulePrefixError(m, *p);
}
}
}
else
{
if(_history.count(*p) == 0)
{
string file = m->definitionContext()->filename();
ostringstream os;
os << _msg << " `" << *p << "'" << endl;
emitWarning(file, m->line(), os.str());
_history.insert(*p);
}
error = true;
}
}
if(!error && !foundPrefix)
{
StringList names = splitScopedName(m->scoped());
string name;
for(StringList::const_iterator i = names.begin(); i != names.end(); ++i)
{
name += *i;
}
if(!addModule(m, name))
{
modulePrefixError(m, "");
}
}
}
}
示例3: getMetaData
void
Slice::ObjCGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
{
ModulePtr m = ModulePtr::dynamicCast(cont);
if(m)
{
bool error = false;
bool foundPrefix = false;
StringList meta = getMetaData(m);
for(StringList::iterator p = meta.begin(); p != meta.end();)
{
string s = *p++;
const string prefix = "objc:prefix:";
string name;
if(s.find(prefix) == 0)
{
foundPrefix = true;
name = trim(s.substr(prefix.size()));
if(name.empty())
{
m->definitionContext()->warning(InvalidMetaData, m->definitionContext()->filename(),
m->line(), _msg + " `" + s + "'");
meta.remove(s);
error = true;
}
else
{
if(!addModule(m, name))
{
modulePrefixError(m, s);
}
}
}
else
{
m->definitionContext()->warning(InvalidMetaData, m->definitionContext()->filename(),
m->line(), _msg + " `" + s + "'");
meta.remove(s);
error = true;
}
}
setMetaData(m, meta);
if(!error && !foundPrefix)
{
StringList names = splitScopedName(m->scoped());
string name;
for(StringList::const_iterator i = names.begin(); i != names.end(); ++i)
{
name += *i;
}
if(!addModule(m, name))
{
modulePrefixError(m, "");
}
}
}
EnumPtr en = EnumPtr::dynamicCast(cont);
if(en)
{
StringList meta = getMetaData(en);
for(StringList::iterator p = meta.begin(); p != meta.end();)
{
string s = *p;
if(s != "objc:scoped")
{
en->definitionContext()->warning(InvalidMetaData, en->definitionContext()->filename(),
en->line(), _msg + " `" + s + "'");
meta.erase(p++);
}
else
{
++p;
}
}
setMetaData(en, meta);
}
}