• 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     USCRIPT_CHECK(params != nullptr, return nullptr, "Create params failed");
35     params->AddParams(expression);
36     return params;
37 }
38 
AddParams(ScriptParams * params,UScriptExpression * expression)39 ScriptParams* ScriptParams::AddParams(ScriptParams *params, UScriptExpression *expression)
40 {
41     if (params == nullptr) {
42         params = new(std::nothrow) ScriptParams();
43         USCRIPT_CHECK(params != nullptr, return nullptr, "Create params failed");
44     }
45     params->AddParams(expression);
46     return params;
47 }
48 
AddParams(UScriptExpression * expression)49 void ScriptParams::AddParams(UScriptExpression *expression)
50 {
51     expressionList_.push_back(expression);
52 }
53 } // namespace Uscript
54