| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef AAPT_LINKER_REFERENCELINKER_H |
| 18 |
#define AAPT_LINKER_REFERENCELINKER_H |
| 19 |
|
| 20 |
#include "android-base/macros.h" |
| 21 |
|
| 22 |
#include "Resource.h" |
| 23 |
#include "ResourceValues.h" |
| 24 |
#include "link/Linkers.h" |
| 25 |
#include "process/IResourceTableConsumer.h" |
| 26 |
#include "process/SymbolTable.h" |
| 27 |
#include "xml/XmlDom.h" |
| 28 |
|
| 29 |
namespace aapt { |
| 30 |
|
| 31 |
|
| 32 |
class ReferenceLinkerTransformer : public CloningValueTransformer { |
| 33 |
public: |
| 34 |
ReferenceLinkerTransformer(const CallSite& callsite, IAaptContext* context, SymbolTable* symbols, |
| 35 |
StringPool* string_pool, ResourceTable* table, |
| 36 |
xml::IPackageDeclStack* decl) |
| 37 |
: CloningValueTransformer(string_pool), |
| 38 |
callsite_(callsite), |
| 39 |
context_(context), |
| 40 |
symbols_(symbols), |
| 41 |
table_(table), |
| 42 |
package_decls_(decl) { |
| 43 |
} |
| 44 |
|
| 45 |
std::unique_ptr<Reference> TransformDerived(const Reference* value) override; |
| 46 |
std::unique_ptr<Item> TransformItem(const Reference* value) override; |
| 47 |
std::unique_ptr<Style> TransformDerived(const Style* value) override; |
| 48 |
|
| 49 |
bool HasError() { |
| 50 |
return error_; |
| 51 |
} |
| 52 |
|
| 53 |
private: |
| 54 |
|
| 55 |
|
| 56 |
std::unique_ptr<Item> ParseValueWithAttribute(std::unique_ptr<Item> value, const Attribute* attr); |
| 57 |
|
| 58 |
const CallSite& callsite_; |
| 59 |
IAaptContext* context_; |
| 60 |
SymbolTable* symbols_; |
| 61 |
ResourceTable* table_; |
| 62 |
xml::IPackageDeclStack* package_decls_; |
| 63 |
bool error_ = false; |
| 64 |
}; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
class ReferenceLinker : public IResourceTableConsumer { |
| 70 |
public: |
| 71 |
ReferenceLinker() = default; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
static const SymbolTable::Symbol* ResolveSymbol(const Reference& reference, |
| 77 |
const CallSite& callsite, |
| 78 |
IAaptContext* context, |
| 79 |
SymbolTable* symbols); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
static const SymbolTable::Symbol* ResolveSymbolCheckVisibility(const Reference& reference, |
| 85 |
const CallSite& callsite, |
| 86 |
IAaptContext* context, |
| 87 |
SymbolTable* symbols, |
| 88 |
std::string* out_error); |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
static const SymbolTable::Symbol* ResolveAttributeCheckVisibility(const Reference& reference, |
| 93 |
const CallSite& callsite, |
| 94 |
IAaptContext* context, |
| 95 |
SymbolTable* symbols, |
| 96 |
std::string* out_error); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
static std::optional<xml::AaptAttribute> CompileXmlAttribute(const Reference& reference, |
| 101 |
const CallSite& callsite, |
| 102 |
IAaptContext* context, |
| 103 |
SymbolTable* symbols, |
| 104 |
std::string* out_error); |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
static void WriteAttributeName(const Reference& ref, const CallSite& callsite, |
| 113 |
const xml::IPackageDeclStack* decls, DiagMessage* out_msg); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
static std::unique_ptr<Item> LinkReference(const CallSite& callsite, const Reference& reference, |
| 127 |
IAaptContext* context, SymbolTable* symbols, |
| 128 |
ResourceTable* table, |
| 129 |
const xml::IPackageDeclStack* decls); |
| 130 |
|
| 131 |
|
| 132 |
bool Consume(IAaptContext* context, ResourceTable* table) override; |
| 133 |
|
| 134 |
private: |
| 135 |
DISALLOW_COPY_AND_ASSIGN(ReferenceLinker); |
| 136 |
}; |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
#endif |