-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathpython2js.h
More file actions
69 lines (60 loc) · 2.03 KB
/
Copy pathpython2js.h
File metadata and controls
69 lines (60 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef PYTHON2JS_H
#define PYTHON2JS_H
/** Translate Python objects to JavaScript.
*/
// clang-format off
#define PY_SSIZE_T_CLEAN
#include "Python.h"
// clang-format on
#include "jslib.h"
/**
* Do a shallow conversion from python to JavaScript. Convert immutable types
* with equivalent JavaScript immutable types, but all other types are proxied.
*/
JsVal
python2js(PyObject* x);
JsVal
python2js_inner(PyObject* x,
JsVal proxies,
bool track_proxies,
bool gc_register,
bool is_json_adaptor);
/**
* Like python2js except in the handling of PyProxy creation.
*
* If proxies is NULL, will throw an error instead of creating a PyProxy.
* Otherwise, proxies should be an Array and python2js_track_proxies will add
* the proxy to the array if one is created.
*/
JsVal
python2js_track_proxies(PyObject* x, JsVal proxies, bool gc_register);
/**
* Convert a Python object to a JavaScript object, copying standard collections
* into javascript down to specified depth
* \param x The Python object
* \param depth The maximum depth to copy
* \param proxies If this is Null, will raise an error if we have no JavaScript
* conversion for a Python object. If not NULL, should be a JavaScript
* list. We will add all PyProxies created to the list.
* \return The JavaScript object -- might be an Error object in the case of an
* exception.
*/
JsVal
python2js_with_depth(PyObject* x, int depth, JsVal proxies);
/**
* dict_converter should be a JavaScript function that converts an Iterable of
* pairs into the desired JavaScript object. If dict_converter is NULL, we use
* python2js_with_depth which converts dicts to Map (the default)
*/
JsVal
python2js_custom(PyObject* x,
int depth,
JsVal proxies,
JsVal dict_converter,
JsVal default_converter,
JsVal eager_converter);
int
python2js_init(PyObject* core);
extern PyObject* py_jsnull;
extern PyObject* py_JsBigInt;
#endif /* PYTHON2JS_H */