blob: 09d7fab5d265cbf7cecb529111c36aebced66fa0 [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
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 Hinese639eb52010-11-08 19:27:20 -080017#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_PRAGMA_HANDLER_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_PRAGMA_HANDLER_H_
Shih-wei Liao462aefd2010-06-04 15:32:04 -070019
20#include <string>
21
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070022#include "clang/Lex/Pragma.h"
Shih-wei Liao462aefd2010-06-04 15:32:04 -070023
24namespace clang {
zonr6315f762010-10-05 15:35:14 +080025 class Token;
26 class IdentifierInfo;
27 class Preprocessor;
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070028}
Shih-wei Liao462aefd2010-06-04 15:32:04 -070029
30namespace slang {
31
zonr6315f762010-10-05 15:35:14 +080032 class RSContext;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070033
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070034class RSPragmaHandler : public clang::PragmaHandler {
35 protected:
36 RSContext *mContext;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070037
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070038 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 }
Shih-wei Liao462aefd2010-06-04 15:32:04 -070046
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070047 virtual void handleItem(const std::string &Item) { return; }
Stephen Hines7aff4a02011-12-08 18:34:27 -080048 virtual void handleInt(clang::Preprocessor &PP, clang::Token &Tok,
49 const int v) { return; }
Shih-wei Liao462aefd2010-06-04 15:32:04 -070050
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070051 // Handle pragma like #pragma rs [name] ([item #1],[item #2],...,[item #i])
52 void handleItemListPragma(clang::Preprocessor &PP,
53 clang::Token &FirstToken);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070054
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070055 // Handle pragma like #pragma rs [name]
56 void handleNonParamPragma(clang::Preprocessor &PP,
57 clang::Token &FirstToken);
Victor Hsiehc6718b32010-06-23 09:29:44 +080058
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070059 // Handle pragma like #pragma rs [name] ("string literal")
Stephen Hines9d2c0fa2011-01-05 14:55:18 -080060 void handleOptionalStringLiteralParamPragma(clang::Preprocessor &PP,
Stephen Hines96ab06c2011-01-05 15:29:26 -080061 clang::Token &FirstToken);
62
63 // Handle pragma like #pragma version (integer)
64 void handleIntegerParamPragma(clang::Preprocessor &PP,
65 clang::Token &FirstToken);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070066
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070067 public:
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070068 static RSPragmaHandler *CreatePragmaExportTypeHandler(RSContext *Context);
Stephen Hinese639eb52010-11-08 19:27:20 -080069 static RSPragmaHandler *CreatePragmaJavaPackageNameHandler(
70 RSContext *Context);
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070071 static RSPragmaHandler *CreatePragmaReflectLicenseHandler(RSContext *Context);
Stephen Hines96ab06c2011-01-05 15:29:26 -080072 static RSPragmaHandler *CreatePragmaVersionHandler(RSContext *Context);
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070073
74 virtual void HandlePragma(clang::Preprocessor &PP,
Shih-wei Liaodf5bcce2011-02-28 18:39:23 -080075 clang::PragmaIntroducerKind Introducer,
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070076 clang::Token &FirstToken) = 0;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070077};
78
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070079} // namespace slang
Shih-wei Liao462aefd2010-06-04 15:32:04 -070080
Stephen Hinese639eb52010-11-08 19:27:20 -080081#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_PRAGMA_HANDLER_H_ NOLINT