1 /* 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 32 namespace slang { 33 class RSContext; 34 class RSExportVar; 35 class RSExportFunc; 36 class RSExportForEach; 37 38 class RSReflectionBase { 39 protected: 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); 64 void write(const std::stringstream &t); 65 66 std::string stripRS(const std::string &s) const; 67 68 static bool writeFile(const std::string &filename, const std::vector< std::string > &txt); 69 70 71 private: 72 73 public: 74 virtual ~RSReflectionBase(); 75 76 static std::string genInitValue(const clang::APValue &Val, bool asBool=false); 77 78 }; // class RSReflection 79 80 } // namespace slang 81 82 #endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_REFLECTION_BASE_H_ NOLINT 83