Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyodide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
pyodide
Commits
6cbac839
Commit
6cbac839
authored
May 30, 2018
by
Michael Droettboom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use variable naming convention to make types clearer
parent
593b3536
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
276 additions
and
270 deletions
+276
-270
src/hiwire.c
src/hiwire.c
+72
-72
src/hiwire.h
src/hiwire.h
+21
-21
src/jsproxy.c
src/jsproxy.c
+49
-49
src/pyimport.c
src/pyimport.c
+3
-1
src/pyproxy.c
src/pyproxy.c
+115
-114
src/python2js.c
src/python2js.c
+16
-13
No files found.
src/hiwire.c
View file @
6cbac839
#include <emscripten.h>
#include <emscripten.h>
// TODO: Use consistent naming so it's clear what's an id and what's a concrete value
EM_JS
(
void
,
hiwire_setup
,
(),
{
EM_JS
(
void
,
hiwire_setup
,
(),
{
var
hiwire
=
{
var
hiwire
=
{
objects:
{},
objects:
{},
id_src
:
1
counter
:
1
};
};
Module
.
hiwire_new_value
=
function
(
val
)
{
Module
.
hiwire_new_value
=
function
(
js
val
)
{
var
objects
=
hiwire
.
objects
;
var
objects
=
hiwire
.
objects
;
while
(
hiwire
.
id_src
in
objects
)
{
while
(
hiwire
.
counter
in
objects
)
{
hiwire
.
id_src
=
(
hiwire
.
id_src
+
1
)
%
0x8fffffff
;
hiwire
.
counter
=
(
hiwire
.
counter
+
1
)
%
0x8fffffff
;
}
}
var
id
=
hiwire
.
id_src
;
var
id
val
=
hiwire
.
counter
;
objects
[
id
]
=
val
;
objects
[
id
val
]
=
js
val
;
hiwire
.
id_src
=
(
hiwire
.
id_src
+
1
)
%
0x8fffffff
;
hiwire
.
counter
=
(
hiwire
.
counter
+
1
)
%
0x8fffffff
;
return
id
;
return
id
val
;
};
};
Module
.
hiwire_get_value
=
function
(
id
)
{
Module
.
hiwire_get_value
=
function
(
id
val
)
{
return
hiwire
.
objects
[
id
];
return
hiwire
.
objects
[
id
val
];
};
};
Module
.
hiwire_decref
=
function
(
id
)
{
Module
.
hiwire_decref
=
function
(
id
val
)
{
var
objects
=
hiwire
.
objects
;
var
objects
=
hiwire
.
objects
;
delete
objects
[
id
];
delete
objects
[
id
val
];
};
};
});
});
EM_JS
(
int
,
hiwire_incref
,
(
int
id
),
{
EM_JS
(
int
,
hiwire_incref
,
(
int
id
val
),
{
return
Module
.
hiwire_new_value
(
Module
.
hiwire_get_value
(
id
));
return
Module
.
hiwire_new_value
(
Module
.
hiwire_get_value
(
id
val
));
});
});
EM_JS
(
void
,
hiwire_decref
,
(
int
id
),
{
EM_JS
(
void
,
hiwire_decref
,
(
int
id
val
),
{
Module
.
hiwire_decref
(
id
);
Module
.
hiwire_decref
(
id
val
);
});
});
EM_JS
(
int
,
hiwire_int
,
(
int
val
ue
),
{
EM_JS
(
int
,
hiwire_int
,
(
int
val
),
{
return
Module
.
hiwire_new_value
(
val
ue
);
return
Module
.
hiwire_new_value
(
val
);
});
});
EM_JS
(
int
,
hiwire_double
,
(
double
val
ue
),
{
EM_JS
(
int
,
hiwire_double
,
(
double
val
),
{
return
Module
.
hiwire_new_value
(
val
ue
);
return
Module
.
hiwire_new_value
(
val
);
});
});
EM_JS
(
int
,
hiwire_string_utf8_length
,
(
int
p
ointer
,
int
length
),
{
EM_JS
(
int
,
hiwire_string_utf8_length
,
(
int
p
tr
,
int
len
),
{
var
bytes
=
new
Uint8Array
(
Module
.
HEAPU8
.
buffer
,
p
ointer
,
length
);
var
bytes
=
new
Uint8Array
(
Module
.
HEAPU8
.
buffer
,
p
tr
,
len
);
var
value
=
new
TextDecoder
(
'
utf
-
8
'
).
decode
(
bytes
);
var
jsval
=
new
TextDecoder
(
'
utf
-
8
'
).
decode
(
bytes
);
return
Module
.
hiwire_new_value
(
value
);
return
Module
.
hiwire_new_value
(
jsval
);
});
});
EM_JS
(
int
,
hiwire_string_utf8
,
(
int
p
ointe
r
),
{
EM_JS
(
int
,
hiwire_string_utf8
,
(
int
p
t
r
),
{
return
Module
.
hiwire_new_value
(
UTF8ToString
(
p
ointe
r
));
return
Module
.
hiwire_new_value
(
UTF8ToString
(
p
t
r
));
});
});
EM_JS
(
int
,
hiwire_bytes
,
(
int
p
ointer
,
int
length
),
{
EM_JS
(
int
,
hiwire_bytes
,
(
int
p
tr
,
int
len
),
{
var
bytes
=
new
Uint8Array
(
Module
.
HEAPU8
.
buffer
,
p
ointer
,
length
);
var
bytes
=
new
Uint8Array
(
Module
.
HEAPU8
.
buffer
,
p
tr
,
len
);
return
Module
.
hiwire_new_value
(
bytes
);
return
Module
.
hiwire_new_value
(
bytes
);
});
});
...
@@ -76,83 +74,85 @@ EM_JS(int, hiwire_false, (), {
...
@@ -76,83 +74,85 @@ EM_JS(int, hiwire_false, (), {
return
Module
.
hiwire_new_value
(
false
);
return
Module
.
hiwire_new_value
(
false
);
});
});
EM_JS
(
int
,
hiwire_throw_error
,
(
int
id
),
{
EM_JS
(
int
,
hiwire_throw_error
,
(
int
id
msg
),
{
var
msg
=
Module
.
hiwire_get_value
(
id
);
var
jsmsg
=
Module
.
hiwire_get_value
(
idmsg
);
Module
.
hiwire_decref
(
id
);
Module
.
hiwire_decref
(
id
msg
);
throw
new
Error
(
msg
);
throw
new
Error
(
js
msg
);
});
});
EM_JS
(
int
,
hiwire_array
,
(),
{
EM_JS
(
int
,
hiwire_array
,
(),
{
return
Module
.
hiwire_new_value
([]);
return
Module
.
hiwire_new_value
([]);
});
});
EM_JS
(
void
,
hiwire_push_array
,
(
int
id
,
int
val
),
{
EM_JS
(
void
,
hiwire_push_array
,
(
int
id
arr
,
int
id
val
),
{
Module
.
hiwire_get_value
(
id
).
push
(
Module
.
hiwire_get_value
(
val
));
Module
.
hiwire_get_value
(
id
arr
).
push
(
Module
.
hiwire_get_value
(
id
val
));
});
});
EM_JS
(
int
,
hiwire_object
,
(),
{
EM_JS
(
int
,
hiwire_object
,
(),
{
return
Module
.
hiwire_new_value
({});
return
Module
.
hiwire_new_value
({});
});
});
EM_JS
(
void
,
hiwire_push_object_pair
,
(
int
id
,
int
key
,
int
val
),
{
EM_JS
(
void
,
hiwire_push_object_pair
,
(
int
id
obj
,
int
idkey
,
int
id
val
),
{
var
jsobj
=
Module
.
hiwire_get_value
(
id
);
var
jsobj
=
Module
.
hiwire_get_value
(
id
obj
);
var
jskey
=
Module
.
hiwire_get_value
(
key
);
var
jskey
=
Module
.
hiwire_get_value
(
id
key
);
var
jsval
=
Module
.
hiwire_get_value
(
val
);
var
jsval
=
Module
.
hiwire_get_value
(
id
val
);
jsobj
[
jskey
]
=
jsval
;
jsobj
[
jskey
]
=
jsval
;
});
});
EM_JS
(
int
,
hiwire_get_global
,
(
int
ptr
),
{
EM_JS
(
int
,
hiwire_get_global
,
(
int
idname
),
{
var
idx
=
UTF8ToString
(
ptr
);
var
jsname
=
UTF8ToString
(
idname
);
return
Module
.
hiwire_new_value
(
window
[
idx
]);
return
Module
.
hiwire_new_value
(
window
[
jsname
]);
});
});
EM_JS
(
int
,
hiwire_get_member_string
,
(
int
ptr
,
int
key
),
{
EM_JS
(
int
,
hiwire_get_member_string
,
(
int
idobj
,
int
id
key
),
{
var
js
key
=
UTF8ToString
(
key
);
var
js
obj
=
Module
.
hiwire_get_value
(
idobj
);
var
js
obj
=
Module
.
hiwire_get_value
(
ptr
);
var
js
key
=
UTF8ToString
(
idkey
);
return
Module
.
hiwire_new_value
(
jsobj
[
jskey
]);
return
Module
.
hiwire_new_value
(
jsobj
[
jskey
]);
});
});
EM_JS
(
void
,
hiwire_set_member_string
,
(
int
ptr
,
int
key
,
int
val
),
{
EM_JS
(
void
,
hiwire_set_member_string
,
(
int
idobj
,
int
ptrkey
,
int
idval
),
{
var
jskey
=
UTF8ToString
(
key
);
var
jsobj
=
Module
.
hiwire_get_value
(
idobj
);
Module
.
hiwire_get_value
(
ptr
)[
jskey
]
=
Module
.
hiwire_get_value
(
val
);
var
jskey
=
UTF8ToString
(
ptrkey
);
var
jsval
=
Module
.
hiwire_get_value
(
idval
);
jsobj
[
jskey
]
=
jsval
;
});
});
EM_JS
(
int
,
hiwire_get_member_int
,
(
int
ptr
,
int
idx
),
{
EM_JS
(
int
,
hiwire_get_member_int
,
(
int
idobj
,
int
idx
),
{
var
jsobj
=
Module
.
hiwire_get_value
(
ptr
);
var
jsobj
=
Module
.
hiwire_get_value
(
idobj
);
return
Module
.
hiwire_new_value
(
jsobj
[
idx
]);
return
Module
.
hiwire_new_value
(
jsobj
[
idx
]);
});
});
EM_JS
(
void
,
hiwire_set_member_int
,
(
int
ptr
,
int
idx
,
int
val
),
{
EM_JS
(
void
,
hiwire_set_member_int
,
(
int
idobj
,
int
idx
,
int
id
val
),
{
Module
.
hiwire_get_value
(
ptr
)[
idx
]
=
Module
.
hiwire_get_value
(
val
);
Module
.
hiwire_get_value
(
idobj
)[
idx
]
=
Module
.
hiwire_get_value
(
id
val
);
});
});
EM_JS
(
void
,
hiwire_call
,
(
int
ptr
,
int
args
),
{
EM_JS
(
void
,
hiwire_call
,
(
int
idfunc
,
int
id
args
),
{
var
js
args
=
Module
.
hiwire_get_value
(
args
);
var
js
func
=
Module
.
hiwire_get_value
(
idfunc
);
var
callable
=
Module
.
hiwire_get_value
(
ptr
);
var
jsargs
=
Module
.
hiwire_get_value
(
idargs
);
return
Module
.
hiwire_new_value
(
callable
.
apply
(
callable
,
jsargs
));
return
Module
.
hiwire_new_value
(
jsfunc
.
apply
(
jsfunc
,
jsargs
));
});
});
EM_JS
(
void
,
hiwire_call_member
,
(
int
ptr
,
int
name
,
int
args
),
{
EM_JS
(
void
,
hiwire_call_member
,
(
int
idobj
,
int
ptrname
,
int
id
args
),
{
var
js
name
=
UTF8ToString
(
name
);
var
js
obj
=
Module
.
hiwire_get_value
(
idobj
);
var
js
args
=
Module
.
hiwire_get_value
(
args
);
var
js
name
=
UTF8ToString
(
ptrname
);
var
callable
=
Module
.
hiwire_get_value
(
ptr
);
var
jsargs
=
Module
.
hiwire_get_value
(
idargs
);
return
Module
.
hiwire_new_value
(
callable
[
jsname
].
apply
(
callable
,
jsargs
));
return
Module
.
hiwire_new_value
(
jsobj
[
jsname
].
apply
(
jsobj
,
jsargs
));
});
});
EM_JS
(
void
,
hiwire_new
,
(
int
ptr
,
int
args
),
{
EM_JS
(
void
,
hiwire_new
,
(
int
idobj
,
int
id
args
),
{
var
js
args
=
Module
.
hiwire_get_value
(
args
);
var
js
obj
=
Module
.
hiwire_get_value
(
idobj
);
var
callable
=
Module
.
hiwire_get_value
(
ptr
);
var
jsargs
=
Module
.
hiwire_get_value
(
idargs
);
return
Module
.
hiwire_new_value
(
new
(
Function
.
prototype
.
bind
.
apply
(
callable
,
jsargs
)));
return
Module
.
hiwire_new_value
(
new
(
Function
.
prototype
.
bind
.
apply
(
jsobj
,
jsargs
)));
});
});
EM_JS
(
void
,
hiwire_
length
,
(
int
ptr
),
{
EM_JS
(
void
,
hiwire_
get_length
,
(
int
idobj
),
{
return
Module
.
hiwire_get_value
(
ptr
).
length
;
return
Module
.
hiwire_get_value
(
idobj
).
length
;
});
});
EM_JS
(
void
,
hiwire_is_function
,
(
int
ptr
),
{
EM_JS
(
void
,
hiwire_is_function
,
(
int
idobj
),
{
return
typeof
Module
.
hiwire_get_value
(
ptr
)
===
'
function
'
;
return
typeof
Module
.
hiwire_get_value
(
idobj
)
===
'
function
'
;
});
});
EM_JS
(
void
,
hiwire_to_string
,
(
int
ptr
),
{
EM_JS
(
void
,
hiwire_to_string
,
(
int
idobj
),
{
return
Module
.
hiwire_new_value
(
Module
.
hiwire_get_value
(
ptr
).
toString
());
return
Module
.
hiwire_new_value
(
Module
.
hiwire_get_value
(
idobj
).
toString
());
});
});
src/hiwire.h
View file @
6cbac839
...
@@ -4,32 +4,32 @@
...
@@ -4,32 +4,32 @@
// TODO: Document me
// TODO: Document me
void
hiwire_setup
();
void
hiwire_setup
();
int
hiwire_incref
(
int
);
int
hiwire_incref
(
int
idval
);
void
hiwire_decref
(
int
);
void
hiwire_decref
(
int
idval
);
int
hiwire_int
(
int
);
int
hiwire_int
(
int
val
);
int
hiwire_double
(
double
);
int
hiwire_double
(
double
val
);
int
hiwire_string_utf8_length
(
int
,
int
);
int
hiwire_string_utf8_length
(
int
ptr
,
int
len
);
int
hiwire_string_utf8
(
int
);
int
hiwire_string_utf8
(
int
ptr
);
int
hiwire_bytes
(
int
,
int
);
int
hiwire_bytes
(
int
ptr
,
int
len
);
int
hiwire_undefined
();
int
hiwire_undefined
();
int
hiwire_null
();
int
hiwire_null
();
int
hiwire_true
();
int
hiwire_true
();
int
hiwire_false
();
int
hiwire_false
();
int
hiwire_array
();
int
hiwire_array
();
int
hiwire_push_array
(
int
,
int
);
int
hiwire_push_array
(
int
idobj
,
int
idval
);
int
hiwire_object
();
int
hiwire_object
();
int
hiwire_push_object_pair
(
int
,
int
,
int
);
int
hiwire_push_object_pair
(
int
idobj
,
int
idkey
,
int
idval
);
int
hiwire_throw_error
(
int
);
int
hiwire_throw_error
(
int
idmsg
);
int
hiwire_get_global
(
int
);
int
hiwire_get_global
(
int
ptrname
);
int
hiwire_get_member_string
(
int
,
int
);
int
hiwire_get_member_string
(
int
idobj
,
int
ptrname
);
void
hiwire_set_member_string
(
int
,
int
,
int
);
void
hiwire_set_member_string
(
int
idobj
,
int
ptrname
,
int
idval
);
int
hiwire_get_member_int
(
int
,
int
);
int
hiwire_get_member_int
(
int
idobj
,
int
idx
);
void
hiwire_set_member_int
(
int
,
int
,
int
);
void
hiwire_set_member_int
(
int
idobj
,
int
idx
,
int
idval
);
int
hiwire_call
(
int
,
int
);
int
hiwire_call
(
int
idobj
,
int
idargs
);
int
hiwire_call_member
(
int
,
int
,
int
);
int
hiwire_call_member
(
int
idobj
,
int
ptrname
,
int
idargs
);
int
hiwire_new
(
int
,
int
);
int
hiwire_new
(
int
idobj
,
int
idargs
);
int
hiwire_
length
(
int
);
int
hiwire_
get_length
(
int
idobj
);
int
hiwire_is_function
(
int
);
int
hiwire_is_function
(
int
idobj
);
int
hiwire_to_string
(
int
);
int
hiwire_to_string
(
int
idobj
);
#endif
/* HIWIRE_H */
#endif
/* HIWIRE_H */
src/jsproxy.c
View file @
6cbac839
...
@@ -23,8 +23,8 @@ static void JsProxy_dealloc(JsProxy *self) {
...
@@ -23,8 +23,8 @@ static void JsProxy_dealloc(JsProxy *self) {
static
PyObject
*
JsProxy_Repr
(
PyObject
*
o
)
{
static
PyObject
*
JsProxy_Repr
(
PyObject
*
o
)
{
JsProxy
*
self
=
(
JsProxy
*
)
o
;
JsProxy
*
self
=
(
JsProxy
*
)
o
;
int
js
repr
=
hiwire_to_string
(
self
->
js
);
int
id
repr
=
hiwire_to_string
(
self
->
js
);
PyObject
*
pyrepr
=
jsToPython
(
js
repr
);
PyObject
*
pyrepr
=
jsToPython
(
id
repr
);
return
pyrepr
;
return
pyrepr
;
}
}
...
@@ -43,20 +43,20 @@ static PyObject *JsProxy_GetAttr(PyObject *o, PyObject *attr_name) {
...
@@ -43,20 +43,20 @@ static PyObject *JsProxy_GetAttr(PyObject *o, PyObject *attr_name) {
return
PyObject_GenericGetAttr
(
o
,
attr_name
);
return
PyObject_GenericGetAttr
(
o
,
attr_name
);
}
}
int
v
=
hiwire_get_member_string
(
self
->
js
,
(
int
)
key
);
int
idresult
=
hiwire_get_member_string
(
self
->
js
,
(
int
)
key
);
Py_DECREF
(
str
);
Py_DECREF
(
str
);
if
(
hiwire_is_function
(
v
))
{
if
(
hiwire_is_function
(
idresult
))
{
hiwire_decref
(
v
);
hiwire_decref
(
idresult
);
return
JsBoundMethod_cnew
(
self
->
js
,
key
);
return
JsBoundMethod_cnew
(
self
->
js
,
key
);
}
}
PyObject
*
result
=
jsToPython
(
v
);
PyObject
*
pyresult
=
jsToPython
(
idresult
);
hiwire_decref
(
v
);
hiwire_decref
(
idresult
);
return
result
;
return
py
result
;
}
}
static
int
JsProxy_SetAttr
(
PyObject
*
o
,
PyObject
*
attr_name
,
PyObject
*
value
)
{
static
int
JsProxy_SetAttr
(
PyObject
*
o
,
PyObject
*
attr_name
,
PyObject
*
py
value
)
{
JsProxy
*
self
=
(
JsProxy
*
)
o
;
JsProxy
*
self
=
(
JsProxy
*
)
o
;
PyObject
*
attr_name_py_str
=
PyObject_Str
(
attr_name
);
PyObject
*
attr_name_py_str
=
PyObject_Str
(
attr_name
);
...
@@ -64,9 +64,9 @@ static int JsProxy_SetAttr(PyObject *o, PyObject *attr_name, PyObject *value) {
...
@@ -64,9 +64,9 @@ static int JsProxy_SetAttr(PyObject *o, PyObject *attr_name, PyObject *value) {
return
-
1
;
return
-
1
;
}
}
char
*
key
=
PyUnicode_AsUTF8
(
attr_name_py_str
);
char
*
key
=
PyUnicode_AsUTF8
(
attr_name_py_str
);
int
jsvalue
=
pythonToJs
(
value
);
int
idvalue
=
pythonToJs
(
py
value
);
hiwire_set_member_string
(
self
->
js
,
(
int
)
key
,
js
value
);
hiwire_set_member_string
(
self
->
js
,
(
int
)
key
,
id
value
);
hiwire_decref
(
js
value
);
hiwire_decref
(
id
value
);
Py_DECREF
(
attr_name_py_str
);
Py_DECREF
(
attr_name_py_str
);
return
0
;
return
0
;
...
@@ -77,19 +77,19 @@ static PyObject* JsProxy_Call(PyObject *o, PyObject *args, PyObject *kwargs) {
...
@@ -77,19 +77,19 @@ static PyObject* JsProxy_Call(PyObject *o, PyObject *args, PyObject *kwargs) {
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
int
js
args
=
hiwire_array
();
int
id
args
=
hiwire_array
();
for
(
Py_ssize_t
i
;
i
<
nargs
;
++
i
)
{
for
(
Py_ssize_t
i
;
i
<
nargs
;
++
i
)
{
int
js
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
int
id
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
hiwire_push_array
(
jsargs
,
js
arg
);
hiwire_push_array
(
idargs
,
id
arg
);
hiwire_decref
(
js
arg
);
hiwire_decref
(
id
arg
);
}
}
int
jsresult
=
hiwire_call
(
self
->
js
,
js
args
);
int
idresult
=
hiwire_call
(
self
->
js
,
id
args
);
hiwire_decref
(
js
args
);
hiwire_decref
(
id
args
);
PyObject
*
result
=
jsToPython
(
js
result
);
PyObject
*
pyresult
=
jsToPython
(
id
result
);
hiwire_decref
(
js
result
);
hiwire_decref
(
id
result
);
return
result
;
return
py
result
;
}
}
static
PyObject
*
JsProxy_New
(
PyObject
*
o
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
static
PyObject
*
JsProxy_New
(
PyObject
*
o
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
...
@@ -97,41 +97,41 @@ static PyObject* JsProxy_New(PyObject *o, PyObject *args, PyObject *kwargs) {
...
@@ -97,41 +97,41 @@ static PyObject* JsProxy_New(PyObject *o, PyObject *args, PyObject *kwargs) {
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
int
js
args
=
hiwire_array
();
int
id
args
=
hiwire_array
();
for
(
Py_ssize_t
i
;
i
<
nargs
;
++
i
)
{
for
(
Py_ssize_t
i
;
i
<
nargs
;
++
i
)
{
int
js
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
int
id
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
hiwire_push_array
(
jsargs
,
js
arg
);
hiwire_push_array
(
idargs
,
id
arg
);
hiwire_decref
(
js
arg
);
hiwire_decref
(
id
arg
);
}
}
int
jsresult
=
hiwire_new
(
self
->
js
,
js
args
);
int
idresult
=
hiwire_new
(
self
->
js
,
id
args
);
hiwire_decref
(
js
args
);
hiwire_decref
(
id
args
);
PyObject
*
result
=
jsToPython
(
js
result
);
PyObject
*
pyresult
=
jsToPython
(
id
result
);
hiwire_decref
(
js
result
);
hiwire_decref
(
id
result
);
return
result
;
return
py
result
;
}
}
Py_ssize_t
JsProxy_length
(
PyObject
*
o
)
{
Py_ssize_t
JsProxy_length
(
PyObject
*
o
)
{
JsProxy
*
self
=
(
JsProxy
*
)
o
;
JsProxy
*
self
=
(
JsProxy
*
)
o
;
return
hiwire_length
(
self
->
js
);
return
hiwire_
get_
length
(
self
->
js
);
}
}
PyObject
*
JsProxy_item
(
PyObject
*
o
,
Py_ssize_t
idx
)
{
PyObject
*
JsProxy_item
(
PyObject
*
o
,
Py_ssize_t
idx
)
{
JsProxy
*
self
=
(
JsProxy
*
)
o
;
JsProxy
*
self
=
(
JsProxy
*
)
o
;
int
v
=
hiwire_get_member_int
(
self
->
js
,
idx
);
int
idresult
=
hiwire_get_member_int
(
self
->
js
,
idx
);
PyObject
*
result
=
jsToPython
(
v
);
PyObject
*
pyresult
=
jsToPython
(
idresult
);
hiwire_decref
(
v
);
hiwire_decref
(
idresult
);
return
result
;
return
py
result
;
}
}
int
JsProxy_ass_item
(
PyObject
*
o
,
Py_ssize_t
idx
,
PyObject
*
value
)
{
int
JsProxy_ass_item
(
PyObject
*
o
,
Py_ssize_t
idx
,
PyObject
*
value
)
{
JsProxy
*
self
=
(
JsProxy
*
)
o
;
JsProxy
*
self
=
(
JsProxy
*
)
o
;
int
js_
value
=
pythonToJs
(
value
);
int
id
value
=
pythonToJs
(
value
);
hiwire_set_member_int
(
self
->
js
,
idx
,
js_
value
);
hiwire_set_member_int
(
self
->
js
,
idx
,
id
value
);
hiwire_decref
(
js_
value
);
hiwire_decref
(
id
value
);
return
0
;
return
0
;
}
}
...
@@ -167,10 +167,10 @@ static PyTypeObject JsProxyType = {
...
@@ -167,10 +167,10 @@ static PyTypeObject JsProxyType = {
.
tp_repr
=
JsProxy_Repr
.
tp_repr
=
JsProxy_Repr
};
};
PyObject
*
JsProxy_cnew
(
int
v
)
{
PyObject
*
JsProxy_cnew
(
int
idobj
)
{
JsProxy
*
self
;
JsProxy
*
self
;
self
=
(
JsProxy
*
)
JsProxyType
.
tp_alloc
(
&
JsProxyType
,
0
);
self
=
(
JsProxy
*
)
JsProxyType
.
tp_alloc
(
&
JsProxyType
,
0
);
self
->
js
=
hiwire_incref
(
v
);
self
->
js
=
hiwire_incref
(
idobj
);
return
(
PyObject
*
)
self
;
return
(
PyObject
*
)
self
;
}
}
...
@@ -197,19 +197,19 @@ static PyObject* JsBoundMethod_Call(PyObject *o, PyObject *args, PyObject *kwarg
...
@@ -197,19 +197,19 @@ static PyObject* JsBoundMethod_Call(PyObject *o, PyObject *args, PyObject *kwarg
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
Py_ssize_t
nargs
=
PyTuple_Size
(
args
);
int
js
args
=
hiwire_array
();
int
id
args
=
hiwire_array
();
for
(
Py_ssize_t
i
=
0
;
i
<
nargs
;
++
i
)
{
for
(
Py_ssize_t
i
=
0
;
i
<
nargs
;
++
i
)
{
int
js
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
int
id
arg
=
pythonToJs
(
PyTuple_GET_ITEM
(
args
,
i
));
hiwire_push_array
(
jsargs
,
js
arg
);
hiwire_push_array
(
idargs
,
id
arg
);
hiwire_decref
(
js
arg
);
hiwire_decref
(
id
arg
);
}
}
int
jsresult
=
hiwire_call_member
(
self
->
this_
,
(
int
)
self
->
name
,
js
args
);
int
idresult
=
hiwire_call_member
(
self
->
this_
,
(
int
)
self
->
name
,
id
args
);
hiwire_decref
(
js
args
);
hiwire_decref
(
id
args
);
PyObject
*
result
=
jsToPython
(
js
result
);
PyObject
*
pyresult
=
jsToPython
(
id
result
);
hiwire_decref
(
js
result
);
hiwire_decref
(
id
result
);
return
result
;
return
py
result
;
}
}
static
PyTypeObject
JsBoundMethodType
=
{
static
PyTypeObject
JsBoundMethodType
=
{
...
...
src/pyimport.c
View file @
6cbac839
...
@@ -16,7 +16,9 @@ int pyimport(char *name) {
...
@@ -16,7 +16,9 @@ int pyimport(char *name) {
}
}
Py_DECREF
(
pyname
);
Py_DECREF
(
pyname
);
return
pythonToJs
(
pyval
);
int
idval
=
pythonToJs
(
pyval
);
Py_DECREF
(
pyval
);
return
idval
;
}
}
EM_JS
(
int
,
pyimport_Ready
,
(),
{
EM_JS
(
int
,
pyimport_Ready
,
(),
{
...
...
src/pyproxy.c
View file @
6cbac839
...
@@ -5,49 +5,49 @@
...
@@ -5,49 +5,49 @@
#include "js2python.h"
#include "js2python.h"
#include "python2js.h"
#include "python2js.h"
int
pyproxy_has
(
int
obj
,
int
idx
)
{
int
pyproxy_has
(
int
ptrobj
,
int
idkey
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptr
obj
;
PyObject
*
py
idx
=
jsToPython
(
idx
);
PyObject
*
py
key
=
jsToPython
(
idkey
);
int
result
=
PyObject_HasAttr
(
x
,
pyidx
)
?
hiwire_true
()
:
hiwire_false
();
int
result
=
PyObject_HasAttr
(
pyobj
,
pykey
)
?
hiwire_true
()
:
hiwire_false
();
Py_DECREF
(
py
idx
);
Py_DECREF
(
py
key
);
return
result
;
return
result
;
}
}
int
pyproxy_get
(
int
obj
,
int
idx
)
{
int
pyproxy_get
(
int
ptrobj
,
int
idkey
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptr
obj
;
PyObject
*
py
idx
=
jsToPython
(
idx
);
PyObject
*
py
key
=
jsToPython
(
idkey
);
PyObject
*
attr
=
PyObject_GetAttr
(
x
,
pyidx
);
PyObject
*
pyattr
=
PyObject_GetAttr
(
pyobj
,
pykey
);
Py_DECREF
(
py
idx
);
Py_DECREF
(
py
key
);
if
(
attr
==
NULL
)
{
if
(
py
attr
==
NULL
)
{
PyErr_Clear
();
PyErr_Clear
();
return
hiwire_undefined
();
return
hiwire_undefined
();
}
}
int
ret
=
pythonToJs
(
attr
);
int
idattr
=
pythonToJs
(
py
attr
);
Py_DECREF
(
attr
);
Py_DECREF
(
py
attr
);
return
ret
;
return
idattr
;
};
};
int
pyproxy_set
(
int
obj
,
int
idx
,
int
value
)
{
int
pyproxy_set
(
int
ptrobj
,
int
idkey
,
int
idval
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptr
obj
;
PyObject
*
py
idx
=
jsToPython
(
idx
);
PyObject
*
py
key
=
jsToPython
(
idkey
);
PyObject
*
pyval
ue
=
jsToPython
(
value
);
PyObject
*
pyval
=
jsToPython
(
idval
);
int
re
t
=
PyObject_SetAttr
(
x
,
pyidx
,
pyvalue
);
int
re
sult
=
PyObject_SetAttr
(
pyobj
,
pykey
,
pyval
);
Py_DECREF
(
py
idx
);
Py_DECREF
(
py
key
);
Py_DECREF
(
pyval
ue
);
Py_DECREF
(
pyval
);
if
(
ret
)
{
if
(
re
sul
t
)
{
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
return
value
;
return
idval
;
}
}
int
pyproxy_deleteProperty
(
int
obj
,
int
idx
)
{
int
pyproxy_deleteProperty
(
int
ptrobj
,
int
idkey
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptr
obj
;
PyObject
*
py
idx
=
jsToPython
(
idx
);
PyObject
*
py
key
=
jsToPython
(
idkey
);
int
ret
=
PyObject_DelAttr
(
x
,
pyidx
);
int
ret
=
PyObject_DelAttr
(
pyobj
,
pykey
);
Py_DECREF
(
py
idx
);
Py_DECREF
(
py
key
);
if
(
ret
)
{
if
(
ret
)
{
return
pythonExcToJs
();
return
pythonExcToJs
();
...
@@ -56,131 +56,132 @@ int pyproxy_deleteProperty(int obj, int idx) {
...
@@ -56,131 +56,132 @@ int pyproxy_deleteProperty(int obj, int idx) {
return
hiwire_undefined
();
return
hiwire_undefined
();
}
}
int
pyproxy_ownKeys
(
int
obj
)
{
int
pyproxy_ownKeys
(
int
ptrobj
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptrobj
;
PyObject
*
dir
=
PyObject_Dir
(
x
);
PyObject
*
pydir
=
PyObject_Dir
(
pyobj
);
if
(
dir
==
NULL
)
{
if
(
pydir
==
NULL
)
{
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
int
result
=
hiwire_array
();
int
iddir
=
hiwire_array
();
Py_ssize_t
n
=
PyList_Size
(
dir
);
Py_ssize_t
n
=
PyList_Size
(
py
dir
);
for
(
Py_ssize_t
i
=
0
;
i
<
n
;
++
i
)
{
for
(
Py_ssize_t
i
=
0
;
i
<
n
;
++
i
)
{
PyObject
*
entry
=
PyList_GetItem
(
dir
,
i
);
PyObject
*
pyentry
=
PyList_GetItem
(
py
dir
,
i
);
int
jsentry
=
pythonToJs
(
entry
);
int
identry
=
pythonToJs
(
py
entry
);
hiwire_push_array
(
result
,
js
entry
);
hiwire_push_array
(
iddir
,
id
entry
);
hiwire_decref
(
js
entry
);
hiwire_decref
(
id
entry
);
}
}
Py_DECREF
(
dir
);
Py_DECREF
(
py
dir
);
return
result
;
return
iddir
;
}
}
int
pyproxy_enumerate
(
int
obj
)
{
int
pyproxy_enumerate
(
int
ptr
obj
)
{
return
pyproxy_ownKeys
(
obj
);
return
pyproxy_ownKeys
(
ptr
obj
);
}
}
int
pyproxy_apply
(
int
obj
,
int
args
)
{
int
pyproxy_apply
(
int
ptrobj
,
int
id
args
)
{
PyObject
*
x
=
(
PyObject
*
)
obj
;
PyObject
*
pyobj
=
(
PyObject
*
)
ptr
obj
;
Py_ssize_t
length
=
hiwire_
length
(
args
);
Py_ssize_t
length
=
hiwire_
get_length
(
id
args
);
PyObject
*
pyargs
=
PyTuple_New
(
length
);
PyObject
*
pyargs
=
PyTuple_New
(
length
);
for
(
Py_ssize_t
i
=
0
;
i
<
length
;
++
i
)
{
for
(
Py_ssize_t
i
=
0
;
i
<
length
;
++
i
)
{
int
i
tem
=
hiwire_get_member_int
(
args
,
i
);
int
i
ditem
=
hiwire_get_member_int
(
id
args
,
i
);
PyObject
*
pyitem
=
jsToPython
(
item
);
PyObject
*
pyitem
=
jsToPython
(
i
di
tem
);
PyTuple_SET_ITEM
(
pyargs
,
i
,
pyitem
);
PyTuple_SET_ITEM
(
pyargs
,
i
,
pyitem
);
hiwire_decref
(
item
);
hiwire_decref
(
i
di
tem
);
}
}
PyObject
*
result
=
PyObject_Call
(
x
,
pyargs
,
NULL
);
PyObject
*
pyresult
=
PyObject_Call
(
pyobj
,
pyargs
,
NULL
);
if
(
result
==
NULL
)
{
if
(
py
result
==
NULL
)
{
Py_DECREF
(
pyargs
);
Py_DECREF
(
pyargs
);
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
int
jsresult
=
pythonToJs
(
result
);
int
idresult
=
pythonToJs
(
py
result
);
Py_DECREF
(
result
);
Py_DECREF
(
py
result
);
Py_DECREF
(
pyargs
);
Py_DECREF
(
pyargs
);
return
js
result
;
return
id
result
;
}
}
EM_JS
(
int
,
pyproxy_new
,
(
int
id
),
{
EM_JS
(
int
,
pyproxy_new
,
(
int
ptrobj
),
{
var
target
=
function
()
{};
var
target
=
function
()
{};
target
[
'$$'
]
=
id
;
target
[
'$$'
]
=
ptrobj
;
return
Module
.
hiwire_new_value
(
new
Proxy
(
target
,
Module
.
PyProxy
));
return
Module
.
hiwire_new_value
(
new
Proxy
(
target
,
Module
.
PyProxy
));
});
});
EM_JS
(
int
,
PyProxy_Ready
,
(),
{
EM_JS
(
int
,
PyProxy_Ready
,
(),
{
Module
.
PyProxy
=
{
Module
.
PyProxy
=
{
isExtensible:
function
()
{
return
true
},
isExtensible:
function
()
{
return
true
},
has:
function
(
obj
,
idx
)
{
has:
function
(
jsobj
,
jskey
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
id
xid
=
Module
.
hiwire_new_value
(
idx
);
var
id
key
=
Module
.
hiwire_new_value
(
jskey
);
var
result
=
_pyproxy_has
(
obj
,
idxid
)
!=
0
;
var
result
=
_pyproxy_has
(
ptrobj
,
idkey
)
!=
0
;
Module
.
hiwire_decref
(
id
xid
);
Module
.
hiwire_decref
(
id
key
);
return
result
;
return
result
;
},
},
get:
function
(
obj
,
idx
)
{
get:
function
(
jsobj
,
jskey
)
{
if
(
idx
===
'
toString
'
)
{
if
(
jskey
===
'
toString
'
)
{
return
function
()
{
return
function
()
{
// TODO: Cache repr
// TODO: Cache repr
var
repr
=
pyodide
.
pyimport
(
'
repr
'
);
var
repr
=
pyodide
.
pyimport
(
'
repr
'
);
return
repr
(
obj
);
return
repr
(
js
obj
);
}
}
}
else
if
(
idx
===
'$$'
)
{
}
else
if
(
jskey
===
'$$'
)
{
return
obj
[
'$$'
];
return
js
obj
[
'$$'
];
}
}
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
id
xid
=
Module
.
hiwire_new_value
(
idx
);
var
id
key
=
Module
.
hiwire_new_value
(
jskey
);
var
resultid
=
_pyproxy_get
(
obj
,
idxid
);
var
idresult
=
_pyproxy_get
(
ptrobj
,
idkey
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
id
xid
);
Module
.
hiwire_decref
(
id
key
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
return
result
;
return
js
result
;
},
},
set:
function
(
obj
,
idx
,
value
)
{
set:
function
(
jsobj
,
jskey
,
jsval
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
id
xid
=
Module
.
hiwire_new_value
(
idx
);
var
id
key
=
Module
.
hiwire_new_value
(
jskey
);
var
valueid
=
Module
.
hiwire_new_value
(
value
);
var
idval
=
Module
.
hiwire_new_value
(
jsval
);
var
resultid
=
_pyproxy_set
(
obj
,
idxid
,
valueid
);
var
idresult
=
_pyproxy_set
(
ptrobj
,
idkey
,
idval
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
id
xid
);
Module
.
hiwire_decref
(
id
key
);
Module
.
hiwire_decref
(
valueid
);
Module
.
hiwire_decref
(
idval
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
return
result
;
return
js
result
;
},
},
deleteProperty:
function
(
obj
,
idx
)
{
deleteProperty:
function
(
jsobj
,
jskey
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
id
xid
=
Module
.
hiwire_new_value
(
idx
);
var
id
key
=
Module
.
hiwire_new_value
(
jskey
);
var
resultid
=
_pyproxy_deleteProperty
(
obj
,
idxid
);
var
idresult
=
_pyproxy_deleteProperty
(
ptrobj
,
idkey
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
Module
.
hiwire_decref
(
id
xid
);
Module
.
hiwire_decref
(
id
key
);
return
result
;
return
js
result
;
},
},
ownKeys:
function
(
obj
)
{
ownKeys:
function
(
js
obj
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
resultid
=
_pyproxy_ownKeys
(
obj
);
var
idresult
=
_pyproxy_ownKeys
(
ptr
obj
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
result
.
push
(
'
toString
'
);
js
result
.
push
(
'
toString
'
);
result
.
push
(
'
prototype
'
);
js
result
.
push
(
'
prototype
'
);
return
result
;
return
js
result
;
},
},
enumerate:
function
(
obj
)
{
enumerate:
function
(
js
obj
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
resultid
=
_pyproxy_enumerate
(
obj
);
var
idresult
=
_pyproxy_enumerate
(
ptr
obj
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
result
.
push
(
'
toString
'
);
js
result
.
push
(
'
toString
'
);
result
.
push
(
'
prototype
'
);
js
result
.
push
(
'
prototype
'
);
return
result
;
return
js
result
;
},
},
apply:
function
(
obj
,
thisArg
,
args
)
{
apply:
function
(
jsobj
,
jsthis
,
js
args
)
{
obj
=
obj
[
'$$'
];
ptrobj
=
js
obj
[
'$$'
];
var
argsid
=
Module
.
hiwire_new_value
(
args
);
var
idargs
=
Module
.
hiwire_new_value
(
js
args
);
var
resultid
=
_pyproxy_apply
(
obj
,
argsid
);
var
idresult
=
_pyproxy_apply
(
ptrobj
,
idargs
);
var
result
=
Module
.
hiwire_get_value
(
resultid
);
var
jsresult
=
Module
.
hiwire_get_value
(
idresult
);
Module
.
hiwire_decref
(
resultid
);
Module
.
hiwire_decref
(
idresult
);
Module
.
hiwire_decref
(
argsid
);
Module
.
hiwire_decref
(
idargs
);
return
result
;
return
js
result
;
},
},
};
};
...
...
src/python2js.c
View file @
6cbac839
...
@@ -142,8 +142,8 @@ int pythonToJs(PyObject *x) {
...
@@ -142,8 +142,8 @@ int pythonToJs(PyObject *x) {
int
jsarray
=
hiwire_array
();
int
jsarray
=
hiwire_array
();
size_t
length
=
PySequence_Size
(
x
);
size_t
length
=
PySequence_Size
(
x
);
for
(
size_t
i
=
0
;
i
<
length
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
length
;
++
i
)
{
PyObject
*
item
=
PySequence_GetItem
(
x
,
i
);
PyObject
*
py
item
=
PySequence_GetItem
(
x
,
i
);
if
(
item
==
NULL
)
{
if
(
py
item
==
NULL
)
{
// If something goes wrong converting the sequence (as is the case with
// If something goes wrong converting the sequence (as is the case with
// Pandas data frames), fallback to the Python object proxy
// Pandas data frames), fallback to the Python object proxy
hiwire_decref
(
jsarray
);
hiwire_decref
(
jsarray
);
...
@@ -151,35 +151,38 @@ int pythonToJs(PyObject *x) {
...
@@ -151,35 +151,38 @@ int pythonToJs(PyObject *x) {
Py_INCREF
(
x
);
Py_INCREF
(
x
);
return
pyproxy_new
((
int
)
x
);
return
pyproxy_new
((
int
)
x
);
}
}
int
jsitem
=
pythonToJs
(
item
);
int
jsitem
=
pythonToJs
(
py
item
);
if
(
jsitem
==
-
1
)
{
if
(
jsitem
==
-
1
)
{
Py_DECREF
(
item
);
Py_DECREF
(
py
item
);
hiwire_decref
(
jsarray
);
hiwire_decref
(
jsarray
);
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
Py_DECREF
(
item
);
Py_DECREF
(
py
item
);
hiwire_push_array
(
jsarray
,
jsitem
);
hiwire_push_array
(
jsarray
,
jsitem
);
hiwire_decref
(
jsitem
);
}
}
return
jsarray
;
return
jsarray
;
}
else
if
(
PyDict_Check
(
x
))
{
}
else
if
(
PyDict_Check
(
x
))
{
int
jsdict
=
hiwire_object
();
int
jsdict
=
hiwire_object
();
PyObject
*
k
,
*
v
;
PyObject
*
pykey
,
*
pyval
;
Py_ssize_t
pos
=
0
;
Py_ssize_t
pos
=
0
;
while
(
PyDict_Next
(
x
,
&
pos
,
&
k
,
&
v
))
{
while
(
PyDict_Next
(
x
,
&
pos
,
&
pykey
,
&
pyval
))
{
int
jsk
=
pythonToJs
(
k
);
int
jsk
ey
=
pythonToJs
(
pykey
);
if
(
jsk
==
-
1
)
{
if
(
jsk
ey
==
-
1
)
{
hiwire_decref
(
jsdict
);
hiwire_decref
(
jsdict
);
// TODO: Return a proxy instead here???
// TODO: Return a proxy instead here???
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
int
jsv
=
pythonToJs
(
v
);
int
jsv
al
=
pythonToJs
(
pyval
);
if
(
jsv
==
-
1
)
{
if
(
jsv
al
==
-
1
)
{
// TODO: Return a proxy instead here???
// TODO: Return a proxy instead here???
hiwire_decref
(
jsk
);
hiwire_decref
(
jsk
ey
);
hiwire_decref
(
jsdict
);
hiwire_decref
(
jsdict
);
return
pythonExcToJs
();
return
pythonExcToJs
();
}
}
hiwire_push_object_pair
(
jsdict
,
jsk
,
jsv
);
hiwire_push_object_pair
(
jsdict
,
jskey
,
jsval
);
hiwire_decref
(
jskey
);
hiwire_decref
(
jsval
);
}
}
return
jsdict
;
return
jsdict
;
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment