blob: ca3d565e24a23f3f443091cf2a6187c1cf129eb2 [file] [log] [blame]
Andreas Huberc9410c72016-07-28 12:18:40 -07001#ifndef SCOPE_H_
2
3#define SCOPE_H_
4
5#include "NamedType.h"
6
7#include <utils/KeyedVector.h>
Andreas Huber70a59e12016-08-16 12:57:01 -07008#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -07009
10namespace android {
11
Andreas Huber881227d2016-08-02 14:20:21 -070012struct Formatter;
13struct Interface;
Andreas Huberc9410c72016-07-28 12:18:40 -070014
15struct Scope : public NamedType {
Andreas Huber9ed827c2016-08-22 12:31:13 -070016 Scope(const char *localName);
Andreas Huberc9410c72016-07-28 12:18:40 -070017
Andreas Huber39fa7182016-08-19 14:27:33 -070018 bool addType(const char *localName, Type *type, std::string *errorMsg);
Andreas Huber5a545442016-08-03 10:44:56 -070019
Andreas Huberc9410c72016-07-28 12:18:40 -070020 Type *lookupType(const char *name) const;
21
Andreas Huber5345ec22016-07-29 13:33:27 -070022 bool isScope() const override;
Andreas Huber881227d2016-08-02 14:20:21 -070023
24 // Returns the single interface or NULL.
25 Interface *getInterface() const;
26
Andreas Hubera2723d22016-07-29 15:36:07 -070027 bool containsSingleInterface(std::string *ifaceName) const;
Andreas Huberc9410c72016-07-28 12:18:40 -070028
Andreas Huberc7dfef32016-08-16 10:57:14 -070029 std::string pickUniqueAnonymousName() const;
30
Andreas Huber2831d512016-08-15 09:33:47 -070031 std::string getJavaType() const override;
32
Andreas Huber881227d2016-08-02 14:20:21 -070033 status_t emitTypeDeclarations(Formatter &out) const override;
Andreas Huber85eabdb2016-08-25 11:24:49 -070034
35 status_t emitJavaTypeDeclarations(
36 Formatter &out, bool atTopLevel) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070037
38 status_t emitTypeDefinitions(
39 Formatter &out, const std::string prefix) const override;
40
Andreas Huber70a59e12016-08-16 12:57:01 -070041 const std::vector<Type *> &getSubTypes() const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070042
43 status_t emitVtsTypeDeclarations(Formatter &out) const override;
44
Andreas Huber70a59e12016-08-16 12:57:01 -070045 bool isJavaCompatible() const override;
46
Andreas Huber85eabdb2016-08-25 11:24:49 -070047 size_t countTypes() const;
48 const Type *typeAt(size_t index, std::string *name) const;
49
Andreas Huberc9410c72016-07-28 12:18:40 -070050private:
Andreas Huber70a59e12016-08-16 12:57:01 -070051 std::vector<Type *> mTypes;
Andreas Huberc9410c72016-07-28 12:18:40 -070052 KeyedVector<std::string, size_t> mTypeIndexByName;
53
Andreas Huberc9410c72016-07-28 12:18:40 -070054 DISALLOW_COPY_AND_ASSIGN(Scope);
55};
56
57} // namespace android
58
59#endif // SCOPE_H_
60