blob: 5a90abec1366c13caee0c7d2965e410858c35ecf [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 Huber2831d512016-08-15 09:33:47 -070034 status_t emitJavaTypeDeclarations(Formatter &out) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070035
36 status_t emitTypeDefinitions(
37 Formatter &out, const std::string prefix) const override;
38
Andreas Huber70a59e12016-08-16 12:57:01 -070039 const std::vector<Type *> &getSubTypes() const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070040
41 status_t emitVtsTypeDeclarations(Formatter &out) const override;
42
Andreas Huber70a59e12016-08-16 12:57:01 -070043 bool isJavaCompatible() const override;
44
Andreas Huberc9410c72016-07-28 12:18:40 -070045private:
Andreas Huber70a59e12016-08-16 12:57:01 -070046 std::vector<Type *> mTypes;
Andreas Huberc9410c72016-07-28 12:18:40 -070047 KeyedVector<std::string, size_t> mTypeIndexByName;
48
Andreas Huberc9410c72016-07-28 12:18:40 -070049 DISALLOW_COPY_AND_ASSIGN(Scope);
50};
51
52} // namespace android
53
54#endif // SCOPE_H_
55