|
| 1 | +//===--------------- DescriptorFinder.h -------------------------*- C++ -*-===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef SWIFT_REFLECTION_DESCRIPTOR_FINDER_H |
| 14 | +#define SWIFT_REFLECTION_DESCRIPTOR_FINDER_H |
| 15 | + |
| 16 | +#include "llvm/ADT/StringRef.h" |
| 17 | + |
| 18 | +namespace swift { |
| 19 | +namespace reflection { |
| 20 | + |
| 21 | +class TypeRef; |
| 22 | + |
| 23 | +/// An abstract interface for a builtin type descriptor. |
| 24 | +struct BuiltinTypeDescriptorBase { |
| 25 | + const uint32_t Size; |
| 26 | + const uint32_t Alignment; |
| 27 | + const uint32_t Stride; |
| 28 | + const uint32_t NumExtraInhabitants; |
| 29 | + const bool IsBitwiseTakable; |
| 30 | + |
| 31 | + BuiltinTypeDescriptorBase(uint32_t Size, uint32_t Alignment, uint32_t Stride, |
| 32 | + uint32_t NumExtraInhabitants, bool IsBitwiseTakable) |
| 33 | + : Size(Size), Alignment(Alignment), Stride(Stride), |
| 34 | + NumExtraInhabitants(NumExtraInhabitants), |
| 35 | + IsBitwiseTakable(IsBitwiseTakable) {} |
| 36 | + |
| 37 | + virtual ~BuiltinTypeDescriptorBase(){}; |
| 38 | + |
| 39 | + virtual llvm::StringRef getMangledTypeName() = 0; |
| 40 | +}; |
| 41 | + |
| 42 | +/// Interface for finding type descriptors. Implementors may provide descriptors |
| 43 | +/// that live inside or outside reflection metadata. |
| 44 | +struct DescriptorFinder { |
| 45 | + virtual ~DescriptorFinder(){}; |
| 46 | + |
| 47 | + virtual std::unique_ptr<BuiltinTypeDescriptorBase> |
| 48 | + getBuiltinTypeDescriptor(const TypeRef *TR) = 0; |
| 49 | +}; |
| 50 | + |
| 51 | +} // namespace reflection |
| 52 | +} // namespace swift |
| 53 | +#endif |
0 commit comments