blob: 1f96723e71016398ce01f937ab5c72631d6addf6 [file] [log] [blame]
Jason Sams1b6a0882012-03-12 15:07:58 -07001/*
2 * Copyright 2012, 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_REFLECTION_BASE_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_REFLECTION_BASE_H_
19
20#include <fstream>
21#include <iostream>
22#include <map>
23#include <set>
24#include <string>
25#include <vector>
26
27#include "llvm/ADT/StringExtras.h"
28
29#include "slang_assert.h"
30#include "slang_rs_export_type.h"
31
32namespace slang {
33 class RSContext;
34 class RSExportVar;
35 class RSExportFunc;
36 class RSExportForEach;
37
38class RSReflectionBase {
39protected:
40 const RSContext *mRSContext;
41
42
43
44 RSReflectionBase(const RSContext *);
45
46
47 bool mVerbose;
48
49 std::string mLicenseNote;
50 std::string mInputFileName;
51
52 std::string mClassName;
53 std::string mOutputPath;
54 std::string mOutputBCFileName;
55
56 std::vector< std::string > mText;
57 std::string mIndent;
58
59 bool openFile(const std::string &name, std::string &errorMsg);
60 void startFile(const std::string &filename);
61 void incIndent();
62 void decIndent();
63 void write(const std::string &t);
Jason Sams192392f2012-03-13 16:22:12 -070064 void write(const std::stringstream &t);
Jason Sams1b6a0882012-03-12 15:07:58 -070065
66 std::string stripRS(const std::string &s) const;
67
Tim Murrayb2fbbb92012-09-28 14:17:30 -070068 bool writeFile(const std::string &filename, const std::vector< std::string > &txt);
Jason Sams1b6a0882012-03-12 15:07:58 -070069
70
71private:
72
73public:
74 virtual ~RSReflectionBase();
75
Jason Sams192392f2012-03-13 16:22:12 -070076 static std::string genInitValue(const clang::APValue &Val, bool asBool=false);
Jason Sams1b6a0882012-03-12 15:07:58 -070077
78}; // class RSReflection
79
80} // namespace slang
81
82#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_REFLECTION_BASE_H_ NOLINT