Skip to content

Commit c6463a8

Browse files
committed
update
1 parent 62ddd0b commit c6463a8

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

backend/Python/PyEngine.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717

1818
#include "PyEngine.h"
1919
#include "../../src/Utils.h"
20-
#include "pydebug.h"
21-
#include "pylifecycle.h"
2220

2321
namespace script::py_backend {
2422

25-
PyEngine::PyEngine(std::shared_ptr<utils::MessageQueue> queue) { Py_Initialize(); }
23+
PyEngine::PyEngine(std::shared_ptr<utils::MessageQueue> queue)
24+
: queue_(queue ? std::move(queue) : std::make_shared<utils::MessageQueue>()) {
25+
Py_Initialize();
26+
}
2627

27-
PyEngine::PyEngine() : PyEngine(std::shared_ptr<utils::MessageQueue>{}) {}
28+
PyEngine::PyEngine() : PyEngine(nullptr) {}
2829

2930
PyEngine::~PyEngine() = default;
3031

@@ -44,9 +45,7 @@ Local<Value> PyEngine::eval(const Local<String>& script, const Local<Value>& sou
4445
return Local<Value>();
4546
}
4647

47-
std::shared_ptr<utils::MessageQueue> PyEngine::messageQueue() {
48-
return std::shared_ptr<utils::MessageQueue>();
49-
}
48+
std::shared_ptr<utils::MessageQueue> PyEngine::messageQueue() { return queue_; }
5049

5150
void PyEngine::gc() {}
5251

backend/Python/PyEngine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
namespace script::py_backend {
2626

2727
class PyEngine : public ScriptEngine {
28-
protected:
28+
private:
29+
std::shared_ptr<::script::utils::MessageQueue> queue_;
30+
2931
public:
3032
PyEngine(std::shared_ptr<::script::utils::MessageQueue> queue);
3133

backend/Python/PyHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SCRIPTX_BEGIN_INCLUDE_LIBRARY
2929
#define PY_SSIZE_T_CLEAN
3030
#endif
3131
#include <Python.h>
32+
#include <pylifecycle.h>
3233
SCRIPTX_END_INCLUDE_LIBRARY
3334

3435
namespace script::py_backend {

backend/Python/trait/TraitNative.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ArgumentsData {
2727
size_t size;
2828
};
2929

30-
struct JscScriptClassState {
30+
struct ScriptClassState {
3131
ScriptEngine* scriptEngine_ = nullptr;
3232
Weak<Object> weakRef_;
3333
};
@@ -41,7 +41,7 @@ struct internal::ImplType<::script::Arguments> {
4141

4242
template <>
4343
struct internal::ImplType<::script::ScriptClass> {
44-
using type = py_backend::JscScriptClassState;
44+
using type = py_backend::ScriptClassState;
4545
};
4646

4747
} // namespace script

backend/Python/trait/TraitScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace py_backend {
2525

2626
class EngineScopeImpl {
2727
public:
28-
explicit EngineScopeImpl(PyEngine &) {
28+
explicit EngineScopeImpl(PyEngine &, PyEngine *) {
2929
// enter engine;
3030
}
3131

backend/Template/trait/TraitNative.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct ArgumentsData {
2626
size_t size;
2727
};
2828

29-
struct JscScriptClassState {
29+
struct ScriptClassState {
3030
ScriptEngine* scriptEngine_ = nullptr;
3131
Weak<Object> weakRef_;
3232
};
@@ -40,7 +40,7 @@ struct internal::ImplType<::script::Arguments> {
4040

4141
template <>
4242
struct internal::ImplType<::script::ScriptClass> {
43-
using type = template_backend::JscScriptClassState;
43+
using type = template_backend::ScriptClassState;
4444
};
4545

4646
} // namespace script

test/cmake/TestEnv.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ elseif (${SCRIPTX_BACKEND} STREQUAL QuickJs)
147147
set(DEVOPS_LIBS_LIBPATH QuickJs CACHE STRING "" FORCE)
148148
elseif (${SCRIPTX_BACKEND} STREQUAL Python)
149149
set(DEVOPS_LIBS_INCLUDE
150-
"/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/include/python3.9/"
150+
"/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Headers/"
151151
CACHE STRING "" FORCE)
152-
set(DEVOPS_LIBS_LIBPATH "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/libpython3.9.dylib" CACHE STRING "" FORCE)
152+
set(DEVOPS_LIBS_LIBPATH "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/Current/lib/libpython3.10.dylib" CACHE STRING "" FORCE)
153153
endif ()

0 commit comments

Comments
 (0)