• 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_param.h"
16 #include "script_expression.h"
17 #include "script_utils.h"
18 
19 using namespace std;
20 
21 namespace Uscript {
~ScriptParams()22 ScriptParams::~ScriptParams()
23 {
24     for (auto iter = expressionList_.begin(); iter != expressionList_.end();) {
25         delete *iter;
26         iter = expressionList_.erase(iter);
27     }
28     this->expressionList_.clear();
29 }
30 
CreateParams(UScriptExpression * expression)31 ScriptParams* ScriptParams::CreateParams(UScriptExpression *expression)
32 {
33     auto params = new(std::nothrow) ScriptParams();
34     if (params == nullptr) {
35         USCRIPT_LOGE("Create params failed");
36         return nullptr;
37     }
38     params->AddParams(expression);
39     return params;
40 }
41 
AddParams(ScriptParams * params,UScriptExpression * expression)42 ScriptParams* ScriptParams::AddParams(ScriptParams *params, UScriptExpression *expression)
43 {
44     if (params == nullptr) {
45         params = new(std::nothrow) ScriptParams();
46         if (params == nullptr) {
47             USCRIPT_LOGE("Create params failed");
48             return nullptr;
49         }
50     }
51     params->AddParams(expression);
52     return params;
53 }
54 
AddParams(UScriptExpression * expression)55 void ScriptParams::AddParams(UScriptExpression *expression)
56 {
57     expressionList_.push_back(expression);
58 }
59 } // namespace Uscript
60