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_PRAGMA_HANDLER_H_ // NOLINT 18 #define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_PRAGMA_HANDLER_H_ 19 20 #include <string> 21 22 #include "clang/Lex/Pragma.h" 23 24 namespace clang { 25 class Token; 26 class IdentifierInfo; 27 class Preprocessor; 28 } 29 30 namespace slang { 31 32 class RSContext; 33 34 class RSPragmaHandler : public clang::PragmaHandler { 35 protected: 36 RSContext *mContext; 37 38 RSPragmaHandler(llvm::StringRef Name, RSContext *Context) 39 : clang::PragmaHandler(Name), 40 mContext(Context) { 41 return; 42 } 43 RSContext *getContext() const { 44 return this->mContext; 45 } 46 47 virtual void handleItem(const std::string &Item) { return; } 48 virtual void handleInt(clang::Preprocessor &PP, clang::Token &Tok, 49 const int v) { return; } 50 51 // Handle pragma like #pragma rs [name] ([item #1],[item #2],...,[item #i]) 52 void handleItemListPragma(clang::Preprocessor &PP, 53 clang::Token &FirstToken); 54 55 // Handle pragma like #pragma rs [name] 56 void handleNonParamPragma(clang::Preprocessor &PP, 57 clang::Token &FirstToken); 58 59 // Handle pragma like #pragma rs [name] ("string literal") 60 void handleOptionalStringLiteralParamPragma(clang::Preprocessor &PP, 61 clang::Token &FirstToken); 62 63 // Handle pragma like #pragma version (integer) 64 void handleIntegerParamPragma(clang::Preprocessor &PP, 65 clang::Token &FirstToken); 66 67 public: 68 static RSPragmaHandler *CreatePragmaExportTypeHandler(RSContext *Context); 69 static RSPragmaHandler *CreatePragmaJavaPackageNameHandler( 70 RSContext *Context); 71 static RSPragmaHandler *CreatePragmaReflectLicenseHandler(RSContext *Context); 72 static RSPragmaHandler *CreatePragmaVersionHandler(RSContext *Context); 73 74 virtual void HandlePragma(clang::Preprocessor &PP, 75 clang::PragmaIntroducerKind Introducer, 76 clang::Token &FirstToken) = 0; 77 }; 78 79 } // namespace slang 80 81 #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_PRAGMA_HANDLER_H_ NOLINT 82