1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ACELITE_VERSION_MODULE_H 17 #define OHOS_ACELITE_VERSION_MODULE_H 18 19 #include "acelite_config.h" 20 #include "js_config.h" 21 #include "non_copyable.h" 22 #if IS_ENABLED(ACE_LITE_VERSION_JS_API) 23 #include "presets/preset_module.h" 24 namespace OHOS { 25 namespace ACELite { 26 class VersionModule final : public PresetModule { 27 public: 28 ACE_DISALLOW_COPY_AND_MOVE(VersionModule); 29 /** 30 * @fn VersionModule::VersionModule() 31 * 32 * @brief Constructor. 33 */ VersionModule()34 VersionModule() : PresetModule(nullptr) {} 35 36 /** 37 * @fn VersionModule::~VersionModule() 38 * 39 * @brief Constructor. 40 */ 41 ~VersionModule() = default; 42 43 void Init() override; 44 45 private: 46 static jerry_value_t GetACEVersion(const jerry_value_t func, 47 const jerry_value_t context, 48 const jerry_value_t args[], 49 const jerry_length_t argsNum); 50 51 static jerry_value_t GetACECommit(const jerry_value_t func, 52 const jerry_value_t context, 53 const jerry_value_t args[], 54 const jerry_length_t argsNum); 55 56 static jerry_value_t GetACEBuildStamp(const jerry_value_t func, 57 const jerry_value_t context, 58 const jerry_value_t args[], 59 const jerry_length_t argsNum); 60 }; 61 } // namespace ACELite 62 } // namespace OHOS 63 #endif // ENABLED(ACE_LITE_VERSION_JS_API) 64 namespace OHOS { 65 namespace ACELite { 66 class AceVersionModule final { 67 public: 68 ACE_DISALLOW_COPY_AND_MOVE(AceVersionModule); 69 AceVersionModule() = default; 70 ~AceVersionModule() = default; Load()71 static void Load() 72 { 73 #if IS_ENABLED(ACE_LITE_VERSION_JS_API) 74 VersionModule versionModule; 75 versionModule.Init(); 76 #endif 77 } 78 }; 79 } // namespace ACELite 80 } // namespace OHOS 81 #endif // OHOS_ACELITE_VERSION_MODULE_H 82