1 /* 2 * Copyright (c) 2024 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 #ifndef ARK_JS_NAPI_CLI_JS_RUNTIME_H 17 #define ARK_JS_NAPI_CLI_JS_RUNTIME_H 18 19 #include <uv.h> 20 21 #include <memory> 22 #include <string> 23 24 #include "libpandabase/utils/pandargs.h" 25 #include "native_engine/native_engine.h" 26 27 namespace panda { 28 29 namespace builtins { 30 class TimerModule; 31 } // namespace builtins 32 33 class JsRuntime { 34 public: 35 virtual bool ProcessOptions(int argc, const char **argv, arg_list_t *filenames) = 0; 36 37 virtual bool Init() = 0; 38 39 virtual bool Execute(const std::string &fileName) = 0; 40 41 virtual void Loop() = 0; 42 43 virtual uv_loop_t *GetUVLoop() = 0; 44 45 virtual NativeEngine *GetNativeEngine() = 0; 46 ~JsRuntime()47 virtual ~JsRuntime() {} 48 49 static std::unique_ptr<JsRuntime> Create(); 50 }; 51 52 } // namespace panda 53 54 #endif // ARK_JS_NAPI_CLI_JS_RUNTIME_H 55