blob: d0a1c6220ea337d506c92ece05d79d58a77f9713 [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
zonr6315f762010-10-05 15:35:14 +080017#ifndef _SLANG_COMILER_RS_PRAGMA_HANDLER_H
18#define _SLANG_COMILER_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; }
Shih-wei Liao462aefd2010-06-04 15:32:04 -070048
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070049 // Handle pragma like #pragma rs [name] ([item #1],[item #2],...,[item #i])
50 void handleItemListPragma(clang::Preprocessor &PP,
51 clang::Token &FirstToken);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070052
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070053 // Handle pragma like #pragma rs [name]
54 void handleNonParamPragma(clang::Preprocessor &PP,
55 clang::Token &FirstToken);
Victor Hsiehc6718b32010-06-23 09:29:44 +080056
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070057 // Handle pragma like #pragma rs [name] ("string literal")
zonr6315f762010-10-05 15:35:14 +080058 void handleOptionalStringLiateralParamPragma(clang::Preprocessor &PP,
59 clang::Token &FirstToken);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070060
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070061 public:
62 static RSPragmaHandler *CreatePragmaExportVarHandler(RSContext *Context);
63 static RSPragmaHandler *CreatePragmaExportVarAllHandler(RSContext *Context);
64 static RSPragmaHandler *CreatePragmaExportFuncHandler(RSContext *Context);
65 static RSPragmaHandler *CreatePragmaExportFuncAllHandler(RSContext *Context);
66 static RSPragmaHandler *CreatePragmaExportTypeHandler(RSContext *Context);
67 static RSPragmaHandler *CreatePragmaJavaPackageNameHandler(RSContext *Context);
68 static RSPragmaHandler *CreatePragmaReflectLicenseHandler(RSContext *Context);
69
70 virtual void HandlePragma(clang::Preprocessor &PP,
71 clang::Token &FirstToken) = 0;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070072};
73
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070074} // namespace slang
Shih-wei Liao462aefd2010-06-04 15:32:04 -070075
zonr6315f762010-10-05 15:35:14 +080076#endif // _SLANG_COMILER_RS_PRAGMA_HANDLER_H