1 /*
2 * Copyright (c) 2022 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 <cstring>
17 #include "script_manager.h"
18 #include "script/script_instruction.h"
19
20 using namespace std;
21 using namespace Uscript;
22
23 class UserInstruction1 : public UScriptInstruction {
24 public:
Execute(UScriptEnv & env,UScriptContext & context)25 virtual int32_t Execute(UScriptEnv &env, UScriptContext &context) override
26 {
27 return USCRIPT_SUCCESS;
28 }
29 };
30
31 class UserInstruction2 : public UScriptInstruction {
32 public:
Execute(UScriptEnv & env,UScriptContext & context)33 virtual int32_t Execute(UScriptEnv &env, UScriptContext &context) override
34 {
35 return USCRIPT_SUCCESS;
36 }
37 };
38
39 class UserInstructionFactory : public UScriptInstructionFactory {
40 public:
CreateInstructionInstance(UScriptInstructionPtr & instr,const std::string & name)41 virtual int32_t CreateInstructionInstance(UScriptInstructionPtr& instr, const std::string& name) override
42 {
43 return USCRIPT_SUCCESS;
44 }
UserInstructionFactory()45 UserInstructionFactory()
46 {
47 }
~UserInstructionFactory()48 ~UserInstructionFactory()
49 {
50 }
51 };
52
53 extern "C" {
GetInstructionFactory()54 __attribute__((visibility("default"))) Uscript::UScriptInstructionFactoryPtr GetInstructionFactory()
55 {
56 return new (std::nothrow) UserInstructionFactory;
57 }
58
ReleaseInstructionFactory(Uscript::UScriptInstructionFactoryPtr p)59 __attribute__((visibility("default"))) void ReleaseInstructionFactory(Uscript::UScriptInstructionFactoryPtr p)
60 {
61 delete p;
62 }
63 }