Просмотр исходного кода

Update pubspec.yaml

Update pubspec.yaml

up

Update main.yml

up
blueloveTH 3 лет назад
Родитель
Сommit
46350b0964

+ 1 - 1
.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

+ 5 - 1
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
++ Fix a bug about compile error line number
+
+## 0.4.8+3
+
++ Downgrade to `sdk>=2.17.0`

+ 1 - 8
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
 

+ 2 - 3
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:

+ 14 - 14
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<typename T>
+    inline void push(T&& obj){
+        s_data.push_back(std::forward<T>(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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& _callable, ArgT&& args){
+        return call(_callable, std::forward<ArgT>(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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& obj, const _Str& func, ArgT&& args){
+        return call(getAttr(obj, func), std::forward<ArgT>(args), pkpy::noArg(), false);
     }
 
     inline PyVar call(const PyVar& obj, const _Str& func){

+ 1 - 1
plugins/godot/godot-cpp

@@ -1 +1 @@
-Subproject commit 81b5fc7f112d83abc6fd93824397017e3d837921
+Subproject commit 70637fe5198a3dc5d130781987b3cf2b46de3efc

+ 14 - 14
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<typename T>
+    inline void push(T&& obj){
+        s_data.push_back(std::forward<T>(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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& _callable, ArgT&& args){
+        return call(_callable, std::forward<ArgT>(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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& obj, const _Str& func, ArgT&& args){
+        return call(getAttr(obj, func), std::forward<ArgT>(args), pkpy::noArg(), false);
     }
 
     inline PyVar call(const PyVar& obj, const _Str& func){

+ 4 - 7
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<typename T>
+    inline void push(T&& obj){
+        s_data.push_back(std::forward<T>(obj));
     }
 
 

+ 10 - 7
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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& _callable, ArgT&& args){
+        return call(_callable, std::forward<ArgT>(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<typename ArgT>
+    inline std::enable_if_t<std::is_same_v<std::remove_const_t<std::remove_reference_t<ArgT>>, pkpy::ArgList>, PyVar>
+    call(const PyVar& obj, const _Str& func, ArgT&& args){
+        return call(getAttr(obj, func), std::forward<ArgT>(args), pkpy::noArg(), false);
     }
 
     inline PyVar call(const PyVar& obj, const _Str& func){