Zonr Chang | c383a50 | 2010-10-12 01:52:08 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2010, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 17 | #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ // NOLINT |
| 18 | #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 19 | |
| 20 | #include <string> |
| 21 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 22 | #include "clang/Lex/Token.h" |
| 23 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 24 | #include "llvm/ADT/StringMap.h" |
| 25 | #include "llvm/ADT/StringRef.h" |
| 26 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 27 | #include "slang_rs_export_type.h" |
| 28 | |
| 29 | namespace clang { |
| 30 | class Type; |
| 31 | class DeclaratorDecl; |
| 32 | } // namespace clang |
| 33 | |
| 34 | namespace slang { |
| 35 | |
| 36 | class RSContext; |
| 37 | class RSExportType; |
| 38 | |
| 39 | class RSExportElement { |
| 40 | // This is a utility class for handling the RS_ELEMENT_ADD* marker |
Jean-Luc Brouillet | 796e7b1 | 2014-05-27 11:35:17 -0700 | [diff] [blame] | 41 | RSExportElement() { } |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 42 | |
| 43 | typedef struct { |
Jean-Luc Brouillet | cec9b65 | 2014-05-14 19:33:57 -0700 | [diff] [blame] | 44 | DataType type; |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 45 | bool normalized; |
Stephen Hines | 6e6578a | 2011-02-07 18:05:48 -0800 | [diff] [blame] | 46 | unsigned vsize; |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 47 | } ElementInfo; |
| 48 | |
| 49 | typedef llvm::StringMap<const ElementInfo*> ElementInfoMapTy; |
| 50 | |
| 51 | private: |
| 52 | // Macro name <-> ElementInfo |
| 53 | static ElementInfoMapTy ElementInfoMap; |
| 54 | |
| 55 | static bool Initialized; |
| 56 | |
| 57 | static RSExportType *Create(RSContext *Context, |
| 58 | const clang::Type *T, |
| 59 | const ElementInfo *EI); |
| 60 | |
| 61 | static const ElementInfo *GetElementInfo(const llvm::StringRef &Name); |
Stephen Hines | ecddee3 | 2011-07-20 18:30:09 -0700 | [diff] [blame] | 62 | |
zonr | 6315f76 | 2010-10-05 15:35:14 +0800 | [diff] [blame] | 63 | public: |
| 64 | static void Init(); |
| 65 | |
| 66 | static RSExportType *CreateFromDecl(RSContext *Context, |
| 67 | const clang::DeclaratorDecl *DD); |
| 68 | }; |
| 69 | |
| 70 | } // namespace slang |
| 71 | |
Stephen Hines | e639eb5 | 2010-11-08 19:27:20 -0800 | [diff] [blame] | 72 | #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ NOLINT |