blueloveTH преди 3 години
родител
ревизия
e2762bff3e
променени са 3 файла, в които са добавени 38 реда и са изтрити 53 реда
  1. 29 48
      plugins/flutter/README.md
  2. 8 4
      plugins/flutter/lib/no_web.dart
  3. 1 1
      src/common.h

+ 29 - 48
plugins/flutter/README.md

@@ -1,49 +1,3 @@
-# Welcome to PocketPy
-
-PocketPy is a lightweight(~5000 LOC) Python interpreter for game engines.
-
-It is extremely easy to embed. Including a compiler, optimizer and bytecode virtual machine. All of them are available in a single header file `pocketpy.h`, without external dependencies.
-
-## What it looks like
-
-```python
-def is_prime(x):
-  if x < 2:
-    return False
-  for i in range(2, x):
-    if x % i == 0:
-      return False
-  return True
-
-primes = [i for i in range(2, 20) if is_prime(i)]
-print(primes)
-# [2, 3, 5, 7, 11, 13, 17, 19]
-```
-# basic
-
-The following table shows the basic features of PocketPy with respect to [CPython](https://github.com/python/cpython).
-The features marked with `YES` are supported, and the features marked with `NO` are not supported.
-
-| Name            | Example                         | Supported |
-| --------------- | ------------------------------- | --------- |
-| If Else         | `if..else..elif`                | YES       |
-| Loop            | `for/while/break/continue`      | YES       |
-| Function        | `def f(x,*args,y=1):`           | YES       |
-| Subclass        | `class A(B):`                   | YES       |
-| List            | `[1, 2, 'a']`                   | YES       |
-| ListComp        | `[i for i in range(5)]`         | YES       |
-| Slice           | `a[1:2], a[:2], a[1:]`          | YES       |
-| Tuple           | `(1, 2, 'a')`                   | YES       |
-| Dict            | `{'a': 1, 'b': 2}`              | YES       |
-| F-String        | `f'value is {x}'`               | YES       |
-| Unpacking       | `a, b = 1, 2`                   | YES       |
-| Star Unpacking  | `a, *b = [1, 2, 3]`             | NO        |
-| Exception       | `raise/try..catch`              | YES       |
-| Dynamic Code    | `eval()/exec()`                 | YES       |
-| Reflection      | `hasattr()/getattr()/setattr()` | YES       |
-| Import          | `import/from..import`           | YES       |
-| Context Block   | `with <expr> as <id>:`          | YES       |
-| Type Annotation | `def  f(a: int, b : float = 1)` | YES       |
 
 ## Introduction
 
@@ -185,8 +139,8 @@ class _MyAppState extends State<MyApp> {
     setState(() {
       buffer.write(needMoreLines ? '... $text' : '>>> $text\n');
     });
-    if (text == "exit()") exit(0);
-    needMoreLines = repl.input(text) == 0;
+
+    needMoreLines = repl.input(text);
     refresh();
   }
 
@@ -249,3 +203,30 @@ class _MyAppState extends State<MyApp> {
 }
 ```
 
+# basic
+
+The following table shows the basic features of PocketPy with respect to [CPython](https://github.com/python/cpython).
+The features marked with `YES` are supported, and the features marked with `NO` are not supported.
+
+| Name            | Example                         | Supported |
+| --------------- | ------------------------------- | --------- |
+| If Else         | `if..else..elif`                | YES       |
+| Loop            | `for/while/break/continue`      | YES       |
+| Function        | `def f(x,*args,y=1):`           | YES       |
+| Subclass        | `class A(B):`                   | YES       |
+| List            | `[1, 2, 'a']`                   | YES       |
+| ListComp        | `[i for i in range(5)]`         | YES       |
+| Slice           | `a[1:2], a[:2], a[1:]`          | YES       |
+| Tuple           | `(1, 2, 'a')`                   | YES       |
+| Dict            | `{'a': 1, 'b': 2}`              | YES       |
+| F-String        | `f'value is {x}'`               | YES       |
+| Unpacking       | `a, b = 1, 2`                   | YES       |
+| Star Unpacking  | `a, *b = [1, 2, 3]`             | YES       |
+| Exception       | `raise/try..catch`              | YES       |
+| Dynamic Code    | `eval()/exec()`                 | YES       |
+| Reflection      | `hasattr()/getattr()/setattr()` | YES       |
+| Import          | `import/from..import`           | YES       |
+| Context Block   | `with <expr> as <id>:`          | YES       |
+| Type Annotation | `def  f(a:int, b:float=1)`      | YES       |
+| Generator       | `yield i`                       | YES       |
+| Decorator       | `@cache`                        | YES       |

+ 8 - 4
plugins/flutter/lib/no_web.dart

@@ -28,10 +28,14 @@ class _Bindings {
       ffi.Void Function(ffi.Pointer p),
       void Function(ffi.Pointer p)>("pkpy_delete");
   static final pkpy_setup_callbacks = _lib.lookupFunction<
-      ffi.Void Function(ffi.Pointer f_int, ffi.Pointer f_float,
-          ffi.Pointer f_bool, ffi.Pointer f_str, ffi.Pointer f_None),
-      void Function(ffi.Pointer f_int, ffi.Pointer f_float, ffi.Pointer f_bool,
-          ffi.Pointer f_str, ffi.Pointer f_None)>("pkpy_setup_callbacks");
+      ffi.Void Function(ffi.Pointer _f_int, ffi.Pointer _f_float,
+          ffi.Pointer _f_bool, ffi.Pointer _f_str, ffi.Pointer _f_None),
+      void Function(
+          ffi.Pointer _f_int,
+          ffi.Pointer _f_float,
+          ffi.Pointer _f_bool,
+          ffi.Pointer _f_str,
+          ffi.Pointer _f_None)>("pkpy_setup_callbacks");
   static final pkpy_new_repl = _lib.lookupFunction<
       ffi.Pointer Function(ffi.Pointer vm),
       ffi.Pointer Function(ffi.Pointer vm)>("pkpy_new_repl");

+ 1 - 1
src/common.h

@@ -30,7 +30,7 @@
 #define PK_VERSION				"0.9.3"
 #define PK_EXTRA_CHECK 			0
 
-#if defined(__ANDROID__) && __ANDROID_API__ <= 22
+#if (defined(__ANDROID__) && __ANDROID_API__ <= 22) || defined(__EMSCRIPTEN__)
 #define PK_ENABLE_FILEIO 		0
 #else
 #define PK_ENABLE_FILEIO 		1