Files
swift-mirror/include/swift/ClangImporter/ClangModule.h
Jordan Rose 64debb657d [ClangImporter] Match up classes in generated headers with native classes.
This is necessary to handle Swift code using API defined in Objective-C
that itself uses classes defined in Swift. Protocols coming next.

First half of <rdar://problem/16296027>

Swift SVN r14984
2014-03-13 00:19:10 +00:00

99 lines
3.1 KiB
C++

//===--- ClangModule.h - An imported Clang module ---------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file implements support for loading Clang modules into Swift.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_CLANGIMPORTER_CLANGMODULE_H
#define SWIFT_CLANGIMPORTER_CLANGMODULE_H
#include "swift/AST/Module.h"
namespace clang {
class ASTContext;
class Module;
}
namespace swift {
class ASTContext;
class ClangImporter;
class ModuleLoader;
/// \brief Represents a Clang module that has been imported into Swift.
class ClangModuleUnit final : public LoadedFile {
ClangImporter &owner;
clang::Module *clangModule;
llvm::PointerIntPair<Module *, 1, bool> adapterModule;
~ClangModuleUnit() = default;
public:
/// True if the given Module contains an imported Clang module unit.
static bool hasClangModule(Module *M);
ClangModuleUnit(Module &M, ClangImporter &owner,
clang::Module *clangModule);
/// \brief Retrieve the underlying Clang module.
clang::Module *getClangModule() const { return clangModule; }
/// Returns true if this is a top-level Clang module (not a submodule).
bool isTopLevel() const;
/// Returns the Swift module that overlays this Clang module.
Module *getAdapterModule() const;
virtual bool isSystemModule() const;
virtual void lookupValue(Module::AccessPathTy accessPath,
DeclName name, NLKind lookupKind,
SmallVectorImpl<ValueDecl*> &results) const override;
virtual void lookupVisibleDecls(Module::AccessPathTy accessPath,
VisibleDeclConsumer &consumer,
NLKind lookupKind) const override;
virtual void lookupClassMembers(Module::AccessPathTy accessPath,
VisibleDeclConsumer &consumer) const override;
virtual void
lookupClassMember(Module::AccessPathTy accessPath, DeclName name,
SmallVectorImpl<ValueDecl*> &decls) const override;
virtual void getTopLevelDecls(SmallVectorImpl<Decl*> &results) const override;
virtual void getDisplayDecls(SmallVectorImpl<Decl*> &results) const override;
virtual void
getImportedModules(SmallVectorImpl<Module::ImportedModule> &imports,
Module::ImportFilter filter) const override;
virtual void
collectLinkLibraries(Module::LinkLibraryCallback callback) const override;
virtual StringRef getFilename() const override;
clang::ASTContext &getClangASTContext() const;
static bool classof(const FileUnit *file) {
return file->getKind() == FileUnitKind::ClangModule;
}
static bool classof(const DeclContext *DC) {
return isa<FileUnit>(DC) && classof(cast<FileUnit>(DC));
}
};
}
#endif