• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "script_loadscript.h"
16 #include "script_instruction.h"
17 #include "script_instructionhelper.h"
18 #include "script_manager.h"
19 #include "script_utils.h"
20 
21 using namespace Uscript;
22 
23 namespace BasicInstruction {
Execute(UScriptEnv & env,UScriptContext & context)24 int32_t ScriptLoadScript::Execute(UScriptEnv &env, UScriptContext &context)
25 {
26     ScriptInstructionHelper* helper = ScriptInstructionHelper::GetBasicInstructionHelper();
27     USCRIPT_CHECK(helper != nullptr, return USCRIPT_INVALID_PARAM, "Failed to get instruction helper");
28 
29     std::string scriptName;
30     int32_t priority = 0;
31     int32_t ret = context.GetParam(0, scriptName);
32     USCRIPT_CHECK(ret == USCRIPT_SUCCESS, return ret, "Failed to get param");
33     ret = context.GetParam(1, priority);
34     USCRIPT_CHECK(ret == USCRIPT_SUCCESS, return ret, "Failed to get param");
35     USCRIPT_LOGI("ScriptLoadScript %s priority:%d", scriptName.c_str(), priority);
36     return helper->AddScript(scriptName, priority);
37 }
38 } // namespace BasicInstruction
39