@node-ctypes/python 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -196
- package/dist/bootstrap.js +102 -21
- package/dist/buffers.js +93 -13
- package/dist/conversions.js +239 -68
- package/dist/executor.js +12 -5
- package/dist/native.d.ts +6 -12
- package/dist/native.js +7 -7
- package/dist/objects.d.ts +2 -1
- package/dist/objects.js +9 -37
- package/dist/platform.js +3 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +465 -233
- package/dist/scheduler.js +452 -153
- package/package.json +6 -2
package/dist/objects.js
CHANGED
|
@@ -28,45 +28,17 @@ async def async_next(self):
|
|
|
28
28
|
def await_value(self):
|
|
29
29
|
return _future("await", self).__await__()
|
|
30
30
|
`;
|
|
31
|
-
function isNativeSlot(value) {
|
|
32
|
-
if (typeof value !== "object" || value === null)
|
|
33
|
-
return false;
|
|
34
|
-
return ("pointer" in value &&
|
|
35
|
-
typeof value.pointer === "bigint" &&
|
|
36
|
-
"release" in value &&
|
|
37
|
-
typeof value.release === "function" &&
|
|
38
|
-
"unref" in value &&
|
|
39
|
-
typeof value.unref === "function" &&
|
|
40
|
-
"setNativeError" in value &&
|
|
41
|
-
typeof value.setNativeError === "function" &&
|
|
42
|
-
"drain" in value &&
|
|
43
|
-
typeof value.drain === "function" &&
|
|
44
|
-
"_callback" in value &&
|
|
45
|
-
typeof value._callback === "object" &&
|
|
46
|
-
value._callback !== null &&
|
|
47
|
-
"setNativeError" in value._callback &&
|
|
48
|
-
typeof value._callback.setNativeError === "function" &&
|
|
49
|
-
"drain" in value._callback &&
|
|
50
|
-
typeof value._callback.drain === "function");
|
|
51
|
-
}
|
|
52
31
|
export function nativeSlot(api, handler, restype, argtypes, notify) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
nativeContext: {
|
|
60
|
-
suspend: api.PyEval_SaveThread,
|
|
61
|
-
resume: api.PyEval_RestoreThread,
|
|
62
|
-
onError: api.PyErr_SetRaisedException,
|
|
63
|
-
...(notify === undefined ? {} : { notify }),
|
|
64
|
-
},
|
|
32
|
+
const created = threadSafeCallback(handler, restype, argtypes, {
|
|
33
|
+
nativeContext: {
|
|
34
|
+
suspend: api.PyEval_SaveThread,
|
|
35
|
+
resume: api.PyEval_RestoreThread,
|
|
36
|
+
onError: api.PyErr_SetRaisedException,
|
|
37
|
+
...(notify === undefined ? {} : { notify }),
|
|
65
38
|
},
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
created.release();
|
|
39
|
+
});
|
|
40
|
+
if (typeof created?.setNativeError !== "function" || typeof created?.drain !== "function") {
|
|
41
|
+
created?.release?.();
|
|
70
42
|
throw new Error("node-python requires node-ctypes 2.6.0+ with native callback contexts and drain()");
|
|
71
43
|
}
|
|
72
44
|
created.unref();
|
package/dist/platform.js
CHANGED
package/dist/runtime.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare class Python {
|
|
|
83
83
|
* promise, the context manager is exited when it settles.
|
|
84
84
|
*
|
|
85
85
|
* @example python.with(python.builtins.open(file), (f) => f.read())
|
|
86
|
-
* @param {*}
|
|
86
|
+
* @param {*} pending - Context manager (PyObject proxy or promise)
|
|
87
87
|
* @param {Function} body - Called with the value of `__enter__()`
|
|
88
88
|
* @returns {*} What `body` returns (undefined if the error was suppressed)
|
|
89
89
|
*/
|
|
@@ -92,7 +92,7 @@ export declare class Python {
|
|
|
92
92
|
* Python's `async with` statement for asynchronous context managers
|
|
93
93
|
* (`__aenter__` / `__aexit__`), awaited on the asyncio event loop.
|
|
94
94
|
*
|
|
95
|
-
* @param {*}
|
|
95
|
+
* @param {*} pending - Asynchronous context manager (PyObject proxy or promise)
|
|
96
96
|
* @param {Function} body - Called with the value of `__aenter__()`; may be async
|
|
97
97
|
* @returns {Promise<*>} What `body` returns (undefined if the error was suppressed)
|
|
98
98
|
*/
|