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 17 #ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ // NOLINT 18 #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ 19 20 #include <string> 21 22 #include "clang/Lex/Token.h" 23 24 #include "llvm/ADT/StringMap.h" 25 #include "llvm/ADT/StringRef.h" 26 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 41 RSExportElement() { return; } 42 43 typedef struct { 44 RSExportPrimitiveType::DataKind kind; 45 RSExportPrimitiveType::DataType type; 46 bool normalized; 47 unsigned vsize; 48 } ElementInfo; 49 50 typedef llvm::StringMap<const ElementInfo*> ElementInfoMapTy; 51 52 private: 53 // Macro name <-> ElementInfo 54 static ElementInfoMapTy ElementInfoMap; 55 56 static bool Initialized; 57 58 static RSExportType *Create(RSContext *Context, 59 const clang::Type *T, 60 const ElementInfo *EI); 61 62 static const ElementInfo *GetElementInfo(const llvm::StringRef &Name); 63 64 public: 65 static void Init(); 66 67 static RSExportType *CreateFromDecl(RSContext *Context, 68 const clang::DeclaratorDecl *DD); 69 }; 70 71 } // namespace slang 72 73 #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORT_ELEMENT_H_ NOLINT 74