blob: ad140ac958bc897af7314dc75d767b160e3449e3 [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>
8#include <utils/Vector.h>
9
10namespace android {
11
12struct Constant;
Andreas Huber881227d2016-08-02 14:20:21 -070013struct Formatter;
14struct Interface;
Andreas Huberc9410c72016-07-28 12:18:40 -070015
16struct Scope : public NamedType {
Andreas Huber31629bc2016-08-03 09:06:40 -070017 Scope();
Andreas Huberc9410c72016-07-28 12:18:40 -070018
Andreas Huber31629bc2016-08-03 09:06:40 -070019 bool addType(const char *localName, NamedType *type);
Andreas Huber5a545442016-08-03 10:44:56 -070020
Andreas Huberc9410c72016-07-28 12:18:40 -070021 Type *lookupType(const char *name) const;
22
23 bool addConstant(Constant *constant);
24
Andreas Huber5345ec22016-07-29 13:33:27 -070025 bool isScope() const override;
Andreas Huber881227d2016-08-02 14:20:21 -070026
27 // Returns the single interface or NULL.
28 Interface *getInterface() const;
29
Andreas Hubera2723d22016-07-29 15:36:07 -070030 bool containsSingleInterface(std::string *ifaceName) const;
Andreas Huberc9410c72016-07-28 12:18:40 -070031
Andreas Huberc7dfef32016-08-16 10:57:14 -070032 std::string pickUniqueAnonymousName() const;
33
Andreas Huber2831d512016-08-15 09:33:47 -070034 std::string getJavaType() const override;
35
Andreas Huber881227d2016-08-02 14:20:21 -070036 status_t emitTypeDeclarations(Formatter &out) const override;
Andreas Huber2831d512016-08-15 09:33:47 -070037 status_t emitJavaTypeDeclarations(Formatter &out) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070038
39 status_t emitTypeDefinitions(
40 Formatter &out, const std::string prefix) const override;
41
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070042 Vector<Type *> getSubTypes() const;
43
44 status_t emitVtsTypeDeclarations(Formatter &out) const override;
45
Andreas Huberc9410c72016-07-28 12:18:40 -070046private:
47 Vector<Type *> mTypes;
48 KeyedVector<std::string, size_t> mTypeIndexByName;
49
50 KeyedVector<std::string, Constant *> mConstants;
51
52 DISALLOW_COPY_AND_ASSIGN(Scope);
53};
54
55} // namespace android
56
57#endif // SCOPE_H_
58