本文整理汇总了C++中ObjCClass::baseClass方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjCClass::baseClass方法的具体用法?C++ ObjCClass::baseClass怎么用?C++ ObjCClass::baseClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjCClass
的用法示例。
在下文中一共展示了ObjCClass::baseClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: class_with_baseclass
void tst_Lookup::class_with_baseclass()
{
const QByteArray source = "\n"
"@implementation BaseZoo {} -(void)baseDecl; -(void)baseMethod{} @end\n"
"@interface Zoo: BaseZoo {} +(id)alloc; -(id)init; @end\n"
"@implementation Zoo +(id)alloc{} -(id)init{} -(void)dealloc{} @end\n";
Document::Ptr doc = Document::create("class_with_baseclass");
doc->setUtf8Source(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 3U);
Snapshot snapshot;
snapshot.insert(doc);
Document::Ptr emptyDoc = Document::create("<empty>");
ObjCClass *baseZoo = doc->globalSymbolAt(0)->asObjCClass();
QVERIFY(baseZoo);
QVERIFY(!baseZoo->isInterface());
QCOMPARE(baseZoo->memberCount(), 2U);
ObjCClass *zooIface = doc->globalSymbolAt(1)->asObjCClass();
QVERIFY(zooIface);
QVERIFY(zooIface->isInterface());
QVERIFY(zooIface->baseClass()->name() == baseZoo->name());
ObjCClass *zooImpl = doc->globalSymbolAt(2)->asObjCClass();
QVERIFY(zooImpl);
QVERIFY(!zooImpl->isInterface());
QCOMPARE(zooImpl->memberCount(), 3U);
Declaration *baseDecl = baseZoo->memberAt(0)->asDeclaration();
QVERIFY(baseDecl);
QVERIFY(baseDecl->name() && baseDecl->name()->identifier());
QCOMPARE(QLatin1String(baseDecl->name()->identifier()->chars()), QLatin1String("baseDecl"));
ObjCMethod *baseMethod = baseZoo->memberAt(1)->asObjCMethod();
QVERIFY(baseMethod);
QVERIFY(baseMethod->name() && baseMethod->name()->identifier());
QCOMPARE(QLatin1String(baseMethod->name()->identifier()->chars()), QLatin1String("baseMethod"));
const LookupContext context(doc, snapshot);
LookupScope *objClass = context.lookupType(baseZoo->name(), zooImpl->enclosingScope());
QVERIFY(objClass != 0);
QVERIFY(objClass->symbols().contains(baseZoo));
QList<LookupItem> results = context.lookup(baseDecl->name(), zooImpl);
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0).declaration(), baseDecl);
results = context.lookup(baseMethod->name(), zooImpl);
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0).declaration(), baseMethod);
}