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
4da3106a
Commit
4da3106a
authored
Sep 06, 2018
by
Roman Yurchak
Committed by
GitHub
Sep 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #141 from mdboom/avoid-using-utf8tostring
Avoid using UTF8ToString
parents
063600d6
d29fa842
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
src/hiwire.c
src/hiwire.c
+4
-0
src/hiwire.h
src/hiwire.h
+10
-0
src/python2js.c
src/python2js.c
+4
-4
No files found.
src/hiwire.c
View file @
4da3106a
...
...
@@ -67,6 +67,10 @@ EM_JS(int, hiwire_string_utf8, (int ptr), {
return
Module
.
hiwire_new_value
(
UTF8ToString
(
ptr
));
});
EM_JS
(
int
,
hiwire_string_ascii
,
(
int
ptr
),
{
return
Module
.
hiwire_new_value
(
AsciiToString
(
ptr
));
});
EM_JS
(
int
,
hiwire_bytes
,
(
int
ptr
,
int
len
),
{
var
bytes
=
new
Uint8ClampedArray
(
Module
.
HEAPU8
.
buffer
,
ptr
,
len
);
return
Module
.
hiwire_new_value
(
bytes
);
...
...
src/hiwire.h
View file @
4da3106a
...
...
@@ -86,6 +86,16 @@ hiwire_string_ucs1(int ptr, int len);
int
hiwire_string_utf8
(
int
ptr
);
/**
* Create a new Javascript string, given a pointer to a null-terminated buffer
* containing ascii (well, technically latin-1). The string data itself is
* copied.
*
* Returns: New reference
*/
int
hiwire_string_ascii
(
int
ptr
);
/**
* Create a new Javascript Uint8ClampedArray, given a pointer to a buffer and a
* length, in bytes.
...
...
src/python2js.c
View file @
4da3106a
...
...
@@ -21,7 +21,7 @@ pythonexc2js()
int
exc
;
if
(
type
==
NULL
||
type
==
Py_None
||
value
==
NULL
||
value
==
Py_None
)
{
excval
=
hiwire_string_
utf8
((
int
)
"No exception type or value"
);
excval
=
hiwire_string_
ascii
((
int
)
"No exception type or value"
);
PyErr_Print
();
PyErr_Clear
();
goto
exit
;
...
...
@@ -31,7 +31,7 @@ pythonexc2js()
if
(
tbmod
==
NULL
)
{
PyObject
*
repr
=
PyObject_Repr
(
value
);
if
(
repr
==
NULL
)
{
excval
=
hiwire_string_
utf8
((
int
)
"Could not get repr for exception"
);
excval
=
hiwire_string_
ascii
((
int
)
"Could not get repr for exception"
);
}
else
{
excval
=
python2js
(
repr
);
Py_DECREF
(
repr
);
...
...
@@ -46,7 +46,7 @@ pythonexc2js()
}
if
(
format_exception
==
NULL
)
{
excval
=
hiwire_string_
utf8
((
int
)
"Could not get format_exception function"
);
hiwire_string_
ascii
((
int
)
"Could not get format_exception function"
);
}
else
{
PyObject
*
pylines
;
if
(
no_traceback
)
{
...
...
@@ -58,7 +58,7 @@ pythonexc2js()
}
if
(
pylines
==
NULL
)
{
excval
=
hiwire_string_
utf8
((
int
)
"Error calling traceback.format_exception"
);
hiwire_string_
ascii
((
int
)
"Error calling traceback.format_exception"
);
PyErr_Print
();
PyErr_Clear
();
goto
exit
;
...
...
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