diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aefc3ad4..59ffe18c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,7 @@ jobs: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 with: - flutter-version: '3.3.9' + flutter-version: '3.0.0' channel: 'stable' - run: flutter --version - name: Compiling diff --git a/plugins/flutter/CHANGELOG.md b/plugins/flutter/CHANGELOG.md index 82b769c8..d74eb5a5 100644 --- a/plugins/flutter/CHANGELOG.md +++ b/plugins/flutter/CHANGELOG.md @@ -15,4 +15,8 @@ The initial version. Hello, world! + Fix a bug of `bool` + Support type hints + Fix a bug about comment and indentation -+ Fix a bug about compile error line number \ No newline at end of file ++ Fix a bug about compile error line number + +## 0.4.8+3 + ++ Downgrade to `sdk>=2.17.0` \ No newline at end of file diff --git a/plugins/flutter/example/pubspec.yaml b/plugins/flutter/example/pubspec.yaml index cad97b78..07417f62 100644 --- a/plugins/flutter/example/pubspec.yaml +++ b/plugins/flutter/example/pubspec.yaml @@ -20,7 +20,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.18.5 <3.0.0' + sdk: '>=2.17.0 <3.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -48,13 +48,6 @@ dev_dependencies: flutter_test: sdk: flutter - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^2.0.0 - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/plugins/flutter/pubspec.yaml b/plugins/flutter/pubspec.yaml index c97534b3..20abd89b 100644 --- a/plugins/flutter/pubspec.yaml +++ b/plugins/flutter/pubspec.yaml @@ -1,12 +1,11 @@ name: pocketpy description: A lightweight Python interpreter for game engines. -version: 0.4.8+2 +version: 0.4.8+3 homepage: https://pocketpy.dev repository: https://github.com/blueloveth/pocketpy environment: - sdk: '>=2.18.2 <3.0.0' - flutter: ">=2.5.0" + sdk: '>=2.17.0 <3.0.0' dependencies: flutter: diff --git a/plugins/flutter/src/pocketpy.h b/plugins/flutter/src/pocketpy.h index 1ef41d29..c0c12916 100644 --- a/plugins/flutter/src/pocketpy.h +++ b/plugins/flutter/src/pocketpy.h @@ -3779,7 +3779,7 @@ public: } Frame(const CodeObject* code, PyVar _module, PyVarDict&& locals) - : code(code), _module(_module), f_locals(locals) { + : code(code), _module(_module), f_locals(std::move(locals)) { static uint64_t frame_id = 1; id = frame_id++; @@ -3829,12 +3829,9 @@ public: return __deref_pointer(vm, s_data[s_data.size() + n]); } - inline void push(const PyVar& v){ - s_data.push_back(v); - } - - inline void push(PyVar&& v){ - s_data.emplace_back(std::move(v)); + template + inline void push(T&& obj){ + s_data.push_back(std::forward(obj)); } @@ -4315,14 +4312,13 @@ public: } PyVar fastCall(const _Str& name, pkpy::ArgList&& args){ - const PyVar& obj = args[0]; - PyObject* cls = obj->_type.get(); + PyObject* cls = args[0]->_type.get(); while(cls != None.get()) { auto it = cls->attribs.find(name); if(it != cls->attribs.end()) return call(it->second, std::move(args)); cls = cls->attribs[__base__].get(); } - attributeError(obj, name); + attributeError(args[0], name); return nullptr; } @@ -4330,12 +4326,16 @@ public: return call(_callable, pkpy::noArg(), pkpy::noArg(), false); } - inline PyVar call(const PyVar& _callable, pkpy::ArgList args){ - return call(_callable, args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& _callable, ArgT&& args){ + return call(_callable, std::forward(args), pkpy::noArg(), false); } - inline PyVar call(const PyVar& obj, const _Str& func, pkpy::ArgList args){ - return call(getAttr(obj, func), args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& obj, const _Str& func, ArgT&& args){ + return call(getAttr(obj, func), std::forward(args), pkpy::noArg(), false); } inline PyVar call(const PyVar& obj, const _Str& func){ diff --git a/plugins/godot/godot-cpp b/plugins/godot/godot-cpp index 81b5fc7f..70637fe5 160000 --- a/plugins/godot/godot-cpp +++ b/plugins/godot/godot-cpp @@ -1 +1 @@ -Subproject commit 81b5fc7f112d83abc6fd93824397017e3d837921 +Subproject commit 70637fe5198a3dc5d130781987b3cf2b46de3efc diff --git a/plugins/unity/com.bl.pocketpy/Plugins/iOS/pocketpy.h b/plugins/unity/com.bl.pocketpy/Plugins/iOS/pocketpy.h index 1ef41d29..c0c12916 100644 --- a/plugins/unity/com.bl.pocketpy/Plugins/iOS/pocketpy.h +++ b/plugins/unity/com.bl.pocketpy/Plugins/iOS/pocketpy.h @@ -3779,7 +3779,7 @@ public: } Frame(const CodeObject* code, PyVar _module, PyVarDict&& locals) - : code(code), _module(_module), f_locals(locals) { + : code(code), _module(_module), f_locals(std::move(locals)) { static uint64_t frame_id = 1; id = frame_id++; @@ -3829,12 +3829,9 @@ public: return __deref_pointer(vm, s_data[s_data.size() + n]); } - inline void push(const PyVar& v){ - s_data.push_back(v); - } - - inline void push(PyVar&& v){ - s_data.emplace_back(std::move(v)); + template + inline void push(T&& obj){ + s_data.push_back(std::forward(obj)); } @@ -4315,14 +4312,13 @@ public: } PyVar fastCall(const _Str& name, pkpy::ArgList&& args){ - const PyVar& obj = args[0]; - PyObject* cls = obj->_type.get(); + PyObject* cls = args[0]->_type.get(); while(cls != None.get()) { auto it = cls->attribs.find(name); if(it != cls->attribs.end()) return call(it->second, std::move(args)); cls = cls->attribs[__base__].get(); } - attributeError(obj, name); + attributeError(args[0], name); return nullptr; } @@ -4330,12 +4326,16 @@ public: return call(_callable, pkpy::noArg(), pkpy::noArg(), false); } - inline PyVar call(const PyVar& _callable, pkpy::ArgList args){ - return call(_callable, args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& _callable, ArgT&& args){ + return call(_callable, std::forward(args), pkpy::noArg(), false); } - inline PyVar call(const PyVar& obj, const _Str& func, pkpy::ArgList args){ - return call(getAttr(obj, func), args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& obj, const _Str& func, ArgT&& args){ + return call(getAttr(obj, func), std::forward(args), pkpy::noArg(), false); } inline PyVar call(const PyVar& obj, const _Str& func){ diff --git a/src/codeobject.h b/src/codeobject.h index 2af2ab80..618527e7 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -142,7 +142,7 @@ public: } Frame(const CodeObject* code, PyVar _module, PyVarDict&& locals) - : code(code), _module(_module), f_locals(locals) { + : code(code), _module(_module), f_locals(std::move(locals)) { static uint64_t frame_id = 1; id = frame_id++; @@ -192,12 +192,9 @@ public: return __deref_pointer(vm, s_data[s_data.size() + n]); } - inline void push(const PyVar& v){ - s_data.push_back(v); - } - - inline void push(PyVar&& v){ - s_data.emplace_back(std::move(v)); + template + inline void push(T&& obj){ + s_data.push_back(std::forward(obj)); } diff --git a/src/vm.h b/src/vm.h index ee019a72..7a462d1f 100644 --- a/src/vm.h +++ b/src/vm.h @@ -438,14 +438,13 @@ public: } PyVar fastCall(const _Str& name, pkpy::ArgList&& args){ - const PyVar& obj = args[0]; - PyObject* cls = obj->_type.get(); + PyObject* cls = args[0]->_type.get(); while(cls != None.get()) { auto it = cls->attribs.find(name); if(it != cls->attribs.end()) return call(it->second, std::move(args)); cls = cls->attribs[__base__].get(); } - attributeError(obj, name); + attributeError(args[0], name); return nullptr; } @@ -453,12 +452,16 @@ public: return call(_callable, pkpy::noArg(), pkpy::noArg(), false); } - inline PyVar call(const PyVar& _callable, pkpy::ArgList args){ - return call(_callable, args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& _callable, ArgT&& args){ + return call(_callable, std::forward(args), pkpy::noArg(), false); } - inline PyVar call(const PyVar& obj, const _Str& func, pkpy::ArgList args){ - return call(getAttr(obj, func), args, pkpy::noArg(), false); + template + inline std::enable_if_t>, pkpy::ArgList>, PyVar> + call(const PyVar& obj, const _Str& func, ArgT&& args){ + return call(getAttr(obj, func), std::forward(args), pkpy::noArg(), false); } inline PyVar call(const PyVar& obj, const _Str& func){