Skip to content

Commit 69ab692

Browse files
committed
Update README
1 parent 3c2b26a commit 69ab692

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# pythonista-jscore-runtime
22
## JSCore Runtime Framework - Execute JavaScript and WebAssembly in Pythonista 3 natively on iOS with JavaScriptCore.
3-
JSCore Runtime Framework is an experiment in pushing the boundaries of the Python environment and language features in the Pythonista 3 IDE and apps developed with it on iOS. It is an extensive Python 3 mapping of the JavaScriptCore Objective-C and C-APIs via objc-util. Implementing closely analogous Python integrations, wrapping and interop for evaluating JavaScript and WebAssembly in independent and composable JavaScriptCore execution environments from Python 3 applications and scripts. Focused also from a point of view of being a serious attempt to extend vanilla Pythonista 3 to ultimately support Python packages and modules with compiled extensions that can be cross-compiled reliably into WebAssembly.
3+
JSCore Runtime Framework is an experiment in pushing the boundaries of the Python environment and language features in the [Pythonista 3 IDE](https://omz-software.com/pythonista/) and apps developed with it on iOS. It is an extensive Python 3 mapping of the JavaScriptCore Objective-C and C-APIs via objc-util. Implementing closely analogous Python integrations, wrapping and interop for evaluating JavaScript and WebAssembly in independent and composable JavaScriptCore execution environments from Python 3 applications and scripts. Focused also from a point of view of being a serious attempt to extend vanilla Pythonista 3 to ultimately support Python packages and modules with compiled extensions that can be cross-compiled reliably into WebAssembly.
44

55
The projects overall long term goals aim to offer three core capabilities/features:
66
- Evaluate/execute JavaScript and WebAssembly with seamless Python interop as a standalone library for Pythonista 3 based Python 3 apps.
77
- Compile, bundle, import and run custom source code and third party components extensibly with WebAssembly and JavaScript.
88
- Support Python packages/modules with extensions which can be cross-compiled to WebAssmembly from languages such as C.
99

10-
A (very) simple example:
10+
A few (very) simple examples:
1111

1212
```python
1313

@@ -20,10 +20,23 @@ print(context.js.hello_world())
2020
context.js.value_from_python = ["hello", "from", "python", 1, 2.2, 3.333333, {"object":"value", "nested":{"obj":["array", [], {}]}}]
2121
print(context.eval('value_from_python[2] = "javascript"; value_from_python;').value)
2222

23+
context.js.call_python = lambda v: print(f"hello from python {v}!")
24+
context.eval('call_python("called from javascript");')
2325
# output:
2426
# hello world
2527
# ['hello', 'from', 'javascript', 1, 2.2, 3.333333, {'object': 'value', 'nested': {'obj': ['array', [], {}]}}]
28+
# hello from python called from javascript!
2629

30+
context = jscore.webassembly()
31+
# based on https://developer.mozilla.org/en-US/docs/WebAssembly/Guides/Using_the_JavaScript_API#loading_wasm_modules_in_javascript
32+
module = wasm_module.from_file('./simple.wasm')
33+
module.imports.my_namespace.imported_func = lambda *v: print(*v)
34+
context.load_module(module)
35+
module.exports.exported_func()
36+
37+
# output:
38+
# 42
39+
# (written to Pythonistas terminal via imported_func)
2740
```
2841

2942
## Installation

0 commit comments

Comments
 (0)