blob: 0c3ca68c594c2e2f77fe326985263800c5748fd7 [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 Huber2831d512016-08-15 09:33:47 -070032 std::string getJavaType() const override;
33
Andreas Huber881227d2016-08-02 14:20:21 -070034 status_t emitTypeDeclarations(Formatter &out) const override;
Andreas Huber2831d512016-08-15 09:33:47 -070035 status_t emitJavaTypeDeclarations(Formatter &out) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070036
37 status_t emitTypeDefinitions(
38 Formatter &out, const std::string prefix) const override;
39
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070040 Vector<Type *> getSubTypes() const;
41
42 status_t emitVtsTypeDeclarations(Formatter &out) const override;
43
Andreas Huberc9410c72016-07-28 12:18:40 -070044private:
45 Vector<Type *> mTypes;
46 KeyedVector<std::string, size_t> mTypeIndexByName;
47
48 KeyedVector<std::string, Constant *> mConstants;
49
50 DISALLOW_COPY_AND_ASSIGN(Scope);
51};
52
53} // namespace android
54
55#endif // SCOPE_H_
56