|
| 1 | +/* |
| 2 | + * Tencent is pleased to support the open source community by making ScriptX available. |
| 3 | + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +#pragma once |
| 19 | +#include "../../src/Reference.h" |
| 20 | +#include "PyHelper.h" |
| 21 | + |
| 22 | +namespace script::py_backend { |
| 23 | + |
| 24 | +class PyEngine; |
| 25 | + |
| 26 | +class EngineScopeImpl { |
| 27 | + PyGILState_STATE gilState_ = PyGILState_UNLOCKED; |
| 28 | + |
| 29 | + public: |
| 30 | + explicit EngineScopeImpl(PyEngine &, PyEngine *); |
| 31 | + |
| 32 | + ~EngineScopeImpl(); |
| 33 | +}; |
| 34 | + |
| 35 | +class ExitEngineScopeImpl { |
| 36 | + PyThreadState *threadState = nullptr; |
| 37 | + |
| 38 | + public: |
| 39 | + explicit ExitEngineScopeImpl(PyEngine &); |
| 40 | + |
| 41 | + ~ExitEngineScopeImpl(); |
| 42 | +}; |
| 43 | + |
| 44 | +class StackFrameScopeImpl { |
| 45 | + public: |
| 46 | + explicit StackFrameScopeImpl(PyEngine &) {} |
| 47 | + |
| 48 | + template <typename T> |
| 49 | + Local<T> returnValue(const Local<T> &localRef) { |
| 50 | + return localRef; |
| 51 | + } |
| 52 | +}; |
| 53 | +} // namespace script::py_backend |
0 commit comments