#include <jsapi.h>
#include <Python.h>
Go to the source code of this file.
|
size_t | UCS4ToUTF16 (const uint32_t *chars, size_t length, uint16_t *outStr) |
| Function that makes a UTF16-encoded copy of a UCS4 string.
|
|
JS::Value | jsTypeFactory (JSContext *cx, PyObject *object) |
| Function that takes a PyObject and returns a corresponding JS::Value, doing shared memory management when necessary.
|
|
JS::Value | jsTypeFactorySafe (JSContext *cx, PyObject *object) |
| same to jsTypeFactory, but it's guaranteed that no error would be set on the Python error stack, instead return JS null on error, and output a warning in Python-land
|
|
bool | callPyFunc (JSContext *cx, unsigned int argc, JS::Value *vp) |
| Helper function for jsTypeFactory to create a JSFunction* through JS_NewFunction that knows how to call a python function.
|
|
- Author
- Caleb Aikens (caleb.nosp@m.@dis.nosp@m.tribu.nosp@m.tive.nosp@m..netw.nosp@m.ork)
- Date
- 2023-02-15
- Copyright
- Copyright (c) 2023 Distributive Corp.
◆ callPyFunc()
bool callPyFunc |
( |
JSContext * |
cx, |
|
|
unsigned int |
argc, |
|
|
JS::Value * |
vp |
|
) |
| |
Helper function for jsTypeFactory to create a JSFunction* through JS_NewFunction that knows how to call a python function.
- Parameters
-
cx | - Pointer to the JSContext |
argc | - The number of arguments the JSFunction expects |
vp | - The return value of the JSFunction |
- Returns
- true - Function executed successfully
-
false - Function did not execute successfully and an exception has been set
◆ jsTypeFactory()
JS::Value jsTypeFactory |
( |
JSContext * |
cx, |
|
|
PyObject * |
object |
|
) |
| |
Function that takes a PyObject and returns a corresponding JS::Value, doing shared memory management when necessary.
- Parameters
-
cx | - Pointer to the JSContext |
object | - Pointer to the PyObject who's type and value we wish to encapsulate |
- Returns
- JS::Value - A JS::Value corresponding to the PyType
◆ jsTypeFactorySafe()
JS::Value jsTypeFactorySafe |
( |
JSContext * |
cx, |
|
|
PyObject * |
object |
|
) |
| |
same to jsTypeFactory, but it's guaranteed that no error would be set on the Python error stack, instead return JS null
on error, and output a warning in Python-land
◆ UCS4ToUTF16()
size_t UCS4ToUTF16 |
( |
const uint32_t * |
chars, |
|
|
size_t |
length, |
|
|
uint16_t * |
outStr |
|
) |
| |
Function that makes a UTF16-encoded copy of a UCS4 string.
- Parameters
-
chars | - pointer to the UCS4-encoded string |
length | - length of chars in code points |
outStr | - UTF16-encoded out-parameter string |
- Returns
- size_t - length of outStr (counting surrogate pairs as 2)
◆ PythonExternalStringCallbacks