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 #include "version_module.h"
17 #if IS_ENABLED(ACE_LITE_VERSION_JS_API)
18 #include "ace_log.h"
19 #include "ace_version.h"
20 #include "platform_adapter.h"
21
22 namespace OHOS {
23 namespace ACELite {
Init()24 void VersionModule::Init()
25 {
26 CreateNamedFunction("getAceVersion", GetACEVersion);
27 CreateNamedFunction("getAceCommit", GetACECommit);
28 CreateNamedFunction("getAceStamp", GetACEBuildStamp);
29 PrintVersionTrace();
30 }
31
GetACEVersion(const jerry_value_t func,const jerry_value_t context,const jerry_value_t args[],const jerry_length_t argsNum)32 jerry_value_t VersionModule::GetACEVersion(const jerry_value_t func,
33 const jerry_value_t context,
34 const jerry_value_t args[],
35 const jerry_length_t argsNum)
36 {
37 const char * const versionStr = ACEVersion::GetStr();
38 return jerry_create_string(reinterpret_cast<const jerry_char_t *>(versionStr));
39 }
40
GetACECommit(const jerry_value_t func,const jerry_value_t context,const jerry_value_t args[],const jerry_length_t argsNum)41 jerry_value_t VersionModule::GetACECommit(const jerry_value_t func,
42 const jerry_value_t context,
43 const jerry_value_t args[],
44 const jerry_length_t argsNum)
45 {
46 const char * const commitStr = ACEVersion::GetCommit();
47 return jerry_create_string(reinterpret_cast<const jerry_char_t *>(commitStr));
48 }
49
GetACEBuildStamp(const jerry_value_t func,const jerry_value_t context,const jerry_value_t args[],const jerry_length_t argsNum)50 jerry_value_t VersionModule::GetACEBuildStamp(const jerry_value_t func,
51 const jerry_value_t context,
52 const jerry_value_t args[],
53 const jerry_length_t argsNum)
54 {
55 const char * const stampStr = ACEVersion::GetTimeStamp();
56 return jerry_create_string(reinterpret_cast<const jerry_char_t *>(stampStr));
57 }
58 } // namespace ACELite
59 } // namespace OHOS
60 #endif // ENABLED(ACE_LITE_VERSION_JS_API)
61