1 /* 2 * Copyright 2017 WebAssembly Community Group participants 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 WABT_FEATURE_H_ 18 #define WABT_FEATURE_H_ 19 20 #include "src/common.h" 21 22 namespace wabt { 23 24 class OptionParser; 25 26 class Features { 27 public: 28 void AddOptions(OptionParser*); 29 EnableAll()30 void EnableAll() { 31 #define WABT_FEATURE(variable, flag, default_, help) enable_##variable(); 32 #include "src/feature.def" 33 #undef WABT_FEATURE 34 } 35 36 #define WABT_FEATURE(variable, flag, default_, help) \ 37 bool variable##_enabled() const { return variable##_enabled_; } \ 38 void enable_##variable() { set_##variable##_enabled(true); } \ 39 void disable_##variable() { set_##variable##_enabled(false); } \ 40 void set_##variable##_enabled(bool value) { \ 41 variable##_enabled_ = value; \ 42 UpdateDependencies(); \ 43 } 44 #include "src/feature.def" 45 #undef WABT_FEATURE 46 47 private: 48 void UpdateDependencies(); 49 50 #define WABT_FEATURE(variable, flag, default_, help) \ 51 bool variable##_enabled_ = default_; 52 #include "src/feature.def" 53 #undef WABT_FEATURE 54 }; 55 56 } // namespace wabt 57 58 #endif // WABT_FEATURE_H_ 59