本文整理汇总了C++中StructPtr::scoped方法的典型用法代码示例。如果您正苦于以下问题:C++ StructPtr::scoped方法的具体用法?C++ StructPtr::scoped怎么用?C++ StructPtr::scoped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructPtr
的用法示例。
在下文中一共展示了StructPtr::scoped方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typeChange
bool
FreezeScript::AnalyzeInitVisitor::visitStructStart(const StructPtr& v)
{
if(v->isLocal())
{
return false;
}
string scoped = v->scoped();
TypeList l = _oldUnit->lookupTypeNoBuiltin(scoped, false);
if(!l.empty())
{
StructPtr s = StructPtr::dynamicCast(l.front());
if(!s)
{
typeChange(l.front(), scoped, "struct");
}
else
{
return false;
}
}
_out.newline();
_out.newline();
_out << "<!-- struct " << scoped << " -->";
_out << se("init") << attr("type", scoped);
_out << ee;
return false;
}
示例2: typeChange
bool
FreezeScript::AnalyzeTransformVisitor::visitStructStart(const StructPtr& v)
{
if(v->isLocal())
{
return false;
}
string scoped = v->scoped();
if(ignoreType(scoped))
{
return false;
}
TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
if(l.empty())
{
_missingTypes.push_back(scoped);
return false;
}
StructPtr newStruct = StructPtr::dynamicCast(l.front());
if(!newStruct)
{
if(!_ignoreTypeChanges)
{
typeChange(scoped, v, l.front());
}
return false;
}
_out.newline();
_out.newline();
_out << "<!-- struct " << scoped << " -->";
_out << se("transform") << attr("type", scoped);
DataMemberList oldMembers = v->dataMembers();
DataMemberList newMembers = newStruct->dataMembers();
compareMembers(oldMembers, newMembers);
_out << ee;
return false;
}
示例3: typeToString
bool Slice::ChecksumVisitor::visitStructStart(const StructPtr& p)
{
if (p->isLocal()) {
return false;
}
ostringstream ostr;
ostr << "struct " << p->name() << endl;
DataMemberList members = p->dataMembers();
for (DataMemberList::iterator q = members.begin(); q != members.end(); ++q) {
ostr << typeToString((*q)->type()) << ' ' << (*q)->name() << endl;
}
updateMap(p->scoped(), ostr.str());
return false;
}
示例4: __construct
bool
CodeVisitor::visitStructStart(const StructPtr& p)
{
string scoped = p->scoped();
string name = getName(p);
string type = getTypeVar(p);
string abs = getAbsolute(p, _ns);
MemberInfoList memberList;
MemberInfoList::iterator r;
{
DataMemberList members = p->dataMembers();
for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
{
memberList.push_back(MemberInfo());
memberList.back().fixedName = fixIdent((*q)->name());
memberList.back().inherited = false;
memberList.back().dataMember = *q;
}
}
startNamespace(p);
_out << sp << nl << "if(!class_exists('" << escapeName(abs) << "'))";
_out << sb;
_out << nl << "class " << name;
_out << sb;
_out << nl << "public function __construct(";
writeConstructorParams(memberList);
_out << ")";
_out << sb;
for(r = memberList.begin(); r != memberList.end(); ++r)
{
writeAssign(*r);
}
_out << eb;
//
// __toString
//
_out << sp << nl << "public function __toString()";
_out << sb;
_out << nl << "global " << type << ';';
_out << nl << "return IcePHP_stringify($this, " << type << ");";
_out << eb;
if(!memberList.empty())
{
_out << sp;
for(r = memberList.begin(); r != memberList.end(); ++r)
{
_out << nl << "public $" << r->fixedName << ';';
}
}
_out << eb;
//
// Emit the type information.
//
_out << sp << nl << type << " = IcePHP_defineStruct('" << scoped << "', '" << escapeName(abs) << "', array(";
//
// Data members are represented as an array:
//
// ('MemberName', MemberType)
//
// where MemberType is either a primitive type constant (T_INT, etc.) or the id of a constructed type.
//
for(r = memberList.begin(); r != memberList.end(); ++r)
{
if(r != memberList.begin())
{
_out << ", ";
}
_out.inc();
_out << nl << "array('" << r->fixedName << "', ";
writeType(r->dataMember->type());
_out << ')';
_out.dec();
}
_out << "));";
_out << eb;
endNamespace();
return false;
}
示例5: fixIdent
bool
Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
{
string scoped = p->scoped();
string name = fixIdent(p->name(), IdentToUpper);
MemberInfoList memberList;
MemberInfoList::iterator r;
{
DataMemberList members = p->dataMembers();
for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
{
memberList.push_back(MemberInfo());
memberList.back().lowerName = fixIdent((*q)->name(), IdentToLower);
memberList.back().fixedName = fixIdent((*q)->name(), IdentNormal);
memberList.back().inherited = false;
memberList.back().dataMember = *q;
}
}
_out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << ')';
_out.inc();
_out << nl << "class " << name;
_out.inc();
if(!memberList.empty())
{
_out << nl << "def initialize(";
writeConstructorParams(memberList);
_out << ")";
_out.inc();
for(r = memberList.begin(); r != memberList.end(); ++r)
{
_out << nl << '@' << r->fixedName << " = " << r->lowerName;
}
_out.dec();
_out << nl << "end";
}
//
// hash
//
_out << sp << nl << "def hash";
_out.inc();
_out << nl << "_h = 0";
int iter = 0;
for(r = memberList.begin(); r != memberList.end(); ++r)
{
writeHash("@" + r->fixedName, r->dataMember->type(), iter);
}
_out << nl << "_h % 0x7fffffff";
_out.dec();
_out << nl << "end";
//
// ==
//
_out << sp << nl << "def ==(other)";
_out.inc();
_out << nl << "return false if";
_out.inc();
for(r = memberList.begin(); r != memberList.end(); ++r)
{
if(r != memberList.begin())
{
_out << " or";
}
_out << nl << "@" << r->fixedName << " != other." << r->fixedName;
}
_out.dec();
_out << nl << "true";
_out.dec();
_out << nl << "end";
//
// eql?
//
// This method is used to determine the equality of keys in a Hash object.
//
_out << sp << nl << "def eql?(other)";
_out.inc();
_out << nl << "return other.class == self.class && other == self";
_out.dec();
_out << nl << "end";
//
// inspect
//
_out << sp << nl << "def inspect";
_out.inc();
_out << nl << "::Ice::__stringify(self, T_" << name << ")";
_out.dec();
_out << nl << "end";
//
// read/write accessors for data members.
//
if(!memberList.empty())
{
_out << sp << nl << "attr_accessor ";
for(r = memberList.begin(); r != memberList.end(); ++r)
//.........这里部分代码省略.........
示例6: stringTypeToString
string
Slice::outputTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx)
{
static const char* outputBuiltinTable[] =
{
"::Ice::Byte&",
"bool&",
"::Ice::Short&",
"::Ice::Int&",
"::Ice::Long&",
"::Ice::Float&",
"::Ice::Double&",
"::std::string&",
"::Ice::ObjectPtr&",
"::Ice::ObjectPrx&",
"::Ice::LocalObjectPtr&"
};
if(optional)
{
return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx)) +">&";
}
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
if(builtin->kind() == Builtin::KindString)
{
return stringTypeToString(type, metaData, typeCtx) + "&";
}
else
{
return outputBuiltinTable[builtin->kind()];
}
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
return fixKwd(cl->scoped() + "Ptr&");
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
if(findMetaData(st->getMetaData()) == "%class")
{
return fixKwd(st->scoped() + "Ptr&");
}
return fixKwd(st->scoped()) + "&";
}
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
return fixKwd(proxy->_class()->scoped() + "Prx&");
}
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
return sequenceTypeToString(seq, metaData, typeCtx) + "&";
}
DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
if(dict)
{
return dictionaryTypeToString(dict, metaData, typeCtx) + "&";
}
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if(contained)
{
return fixKwd(contained->scoped()) + "&";
}
return "???";
}
示例7: stringTypeToString
string
Slice::outputTypeToString(const TypePtr& type, bool optional, const StringList& metaData, int typeCtx, bool cpp11)
{
static const char* outputBuiltinTable[] =
{
"::Ice::Byte&",
"bool&",
"::Ice::Short&",
"::Ice::Int&",
"::Ice::Long&",
"::Ice::Float&",
"::Ice::Double&",
"::std::string&",
"::Ice::ObjectPtr&",
"::Ice::ObjectPrxPtr&",
"::Ice::LocalObjectPtr&",
"::Ice::ValuePtr&"
};
static const char* cpp11OutputBuiltinTable[] =
{
"::Ice::Byte&",
"bool&",
"short&",
"int&",
"long long int&",
"float&",
"double&",
"::std::string&",
"::std::shared_ptr<::Ice::Object>&",
"::std::shared_ptr<::Ice::ObjectPrx>&",
"::std::shared_ptr<void>&",
"::std::shared_ptr<::Ice::Value>&"
};
if(optional)
{
return "IceUtil::Optional<" + toTemplateArg(typeToString(type, metaData, typeCtx, cpp11)) +">&";
}
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
if(builtin->kind() == Builtin::KindString)
{
return stringTypeToString(type, metaData, typeCtx) + "&";
}
else
{
if(cpp11)
{
if(builtin->kind() == Builtin::KindObject && !(typeCtx & TypeContextLocalOperation))
{
return "::std::shared_ptr<::Ice::Value>";
}
else
{
return cpp11OutputBuiltinTable[builtin->kind()];
}
}
else
{
return outputBuiltinTable[builtin->kind()];
}
}
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
if(cpp11)
{
if(cl->isInterface() && !cl->isLocal())
{
return "::std::shared_ptr<::Ice::Value>&";
}
else
{
return "::std::shared_ptr<" + fixKwd(cl->scoped()) + ">&";
}
}
else
{
return fixKwd(cl->scoped() + "Ptr&");
}
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
if(!cpp11 && findMetaData(st->getMetaData()) == "%class")
{
return fixKwd(st->scoped() + "Ptr&");
}
else
{
return fixKwd(st->scoped()) + "&";
}
}
//.........这里部分代码省略.........
示例8: assert
//.........这里部分代码省略.........
if(cl || (newb && newb->kind() == Builtin::KindObject))
{
return;
}
break;
}
case Builtin::KindObjectProxy:
{
ProxyPtr p = ProxyPtr::dynamicCast(newType);
if(p || (newb && newb->kind() == Builtin::KindObjectProxy) || (newb && newb->kind() == Builtin::KindString))
{
return;
}
break;
}
case Builtin::KindLocalObject:
{
assert(false);
break;
}
}
typeChange(desc, oldType, newType);
return;
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(oldType);
if(cl)
{
if(!cl->definition())
{
_errors.push_back("class " + cl->scoped() + " declared but not defined");
return;
}
//
// Allow target type of Object.
//
BuiltinPtr newb = BuiltinPtr::dynamicCast(newType);
if(newb && newb->kind() == Builtin::KindObject)
{
return;
}
//
// Allow target type of struct.
//
if(StructPtr::dynamicCast(newType))
{
return;
}
ClassDeclPtr newcl = ClassDeclPtr::dynamicCast(newType);
if(newcl)
{
if(!newcl->definition())
{
_errors.push_back("class " + newcl->scoped() + " declared but not defined");
return;
}
if(checkClasses(cl, newcl))
{
return;
示例9: if
bool
FreezeScript::AnalyzeTransformVisitor::visitStructStart(const StructPtr& v)
{
if(v->isLocal())
{
return false;
}
string scoped = v->scoped();
if(ignoreType(scoped))
{
return false;
}
TypeList l = _newUnit->lookupTypeNoBuiltin(scoped, false);
if(l.empty())
{
_missingTypes.push_back(scoped);
return false;
}
//
// Allow transforming from struct to class.
//
StructPtr newStruct = StructPtr::dynamicCast(l.front());
ClassDeclPtr decl = ClassDeclPtr::dynamicCast(l.front());
ClassDefPtr newClass;
if(decl)
{
newClass = decl->definition();
if(!newClass)
{
_missingTypes.push_back(scoped);
return false;
}
}
else if(!newStruct)
{
if(!_ignoreTypeChanges)
{
typeChange(scoped, v, l.front());
}
return false;
}
_out.newline();
_out.newline();
if(newClass)
{
_out << "<!-- class " << scoped << " -->";
}
else
{
_out << "<!-- struct " << scoped << " -->";
}
_out << se("transform") << attr("type", scoped);
DataMemberList oldMembers, newMembers;
if(newClass)
{
oldMembers = v->dataMembers();
newMembers = newClass->allDataMembers();
}
else
{
oldMembers = v->dataMembers();
newMembers = newStruct->dataMembers();
}
compareMembers(oldMembers, newMembers);
_out << ee;
return false;
}