Skip to content

Commit 170abb0

Browse files
committed
Fix "Pointer_stringify is not defined". Based on fernandotcl#9
1 parent 9da5b06 commit 170abb0

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Makefile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
# Build the Javascript version of TinyEMU
2626
EMCC=emcc
27-
EMCFLAGS=-O2 --llvm-opts 2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD -fno-strict-aliasing -DCONFIG_FS_NET
27+
EMCFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD -fno-strict-aliasing -DCONFIG_FS_NET
2828
#EMCFLAGS+=-Werror
29-
EMLDFLAGS=-O3 --memory-init-file 0 --closure 0 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s "EXPORTED_FUNCTIONS=['_console_queue_char','_vm_start','_fs_import_file','_display_key_event','_display_mouse_event','_display_wheel_event','_net_write_packet','_net_set_carrier']" -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' --js-library js/lib.js
29+
EMLDFLAGS=-O3 --memory-init-file 0 --closure 0 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s "EXPORTED_FUNCTIONS=['_console_queue_char','_vm_start','_fs_import_file','_display_key_event','_display_mouse_event','_display_wheel_event','_net_write_packet','_net_set_carrier','_free']" -s 'DYNCALLS=1' -s 'EXPORTED_RUNTIME_METHODS=["ccall", "cwrap", "UTF8ToString"]' --js-library js/lib.js
3030
EMLDFLAGS_ASMJS:=$(EMLDFLAGS) -s WASM=0
3131
EMLDFLAGS_WASM:=$(EMLDFLAGS) -s WASM=1 -s TOTAL_MEMORY=67108864 -s ALLOW_MEMORY_GROWTH=1
3232

js/lib.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mergeInto(LibraryManager.library, {
4141

4242
fs_export_file: function(filename, buf, buf_len)
4343
{
44-
var _filename = Pointer_stringify(filename);
44+
var _filename = UTF8ToString(filename);
4545
// console.log("exporting " + _filename);
4646
var data = HEAPU8.subarray(buf, buf + buf_len);
4747
var file = new Blob([data], { type: "application/octet-stream" });
@@ -58,20 +58,21 @@ mergeInto(LibraryManager.library, {
5858
}, 50);
5959
},
6060

61+
emscripten_async_wget3_data__deps: [ "$wget", "$Browser" ],
6162
emscripten_async_wget3_data: function(url, request, user, password, post_data, post_data_len, arg, free, onload, onerror, onprogress) {
62-
var _url = Pointer_stringify(url);
63-
var _request = Pointer_stringify(request);
63+
var _url = UTF8ToString(url);
64+
var _request = UTF8ToString(request);
6465
var _user;
6566
var _password;
6667

6768
var http = new XMLHttpRequest();
6869

6970
if (user)
70-
_user = Pointer_stringify(user);
71+
_user = UTF8ToString(user);
7172
else
7273
_user = null;
7374
if (password)
74-
_password = Pointer_stringify(password);
75+
_password = UTF8ToString(password);
7576
else
7677
_password = null;
7778

@@ -81,38 +82,38 @@ mergeInto(LibraryManager.library, {
8182
http.setRequestHeader("Authorization", "Basic " + btoa(_user + ':' + _password));
8283
}
8384

84-
var handle = Browser.getNextWgetRequestHandle();
85+
var handle = wget.getNextWgetRequestHandle();
8586

8687
// LOAD
8788
http.onload = function http_onload(e) {
8889
if (http.status == 200 || _url.substr(0,4).toLowerCase() != "http") {
8990
var byteArray = new Uint8Array(http.response);
9091
var buffer = _malloc(byteArray.length);
9192
HEAPU8.set(byteArray, buffer);
92-
if (onload) Runtime.dynCall('viiii', onload, [handle, arg, buffer, byteArray.length]);
93+
if (onload) dynCall('viiii', onload, [handle, arg, buffer, byteArray.length]);
9394
if (free) _free(buffer);
9495
} else {
95-
if (onerror) Runtime.dynCall('viiii', onerror, [handle, arg, http.status, http.statusText]);
96+
if (onerror) dynCall('viiii', onerror, [handle, arg, http.status, http.statusText]);
9697
}
97-
delete Browser.wgetRequests[handle];
98+
delete wget.wgetRequests[handle];
9899
};
99100

100101
// ERROR
101102
http.onerror = function http_onerror(e) {
102103
if (onerror) {
103-
Runtime.dynCall('viiii', onerror, [handle, arg, http.status, http.statusText]);
104+
dynCall('viiii', onerror, [handle, arg, http.status, http.statusText]);
104105
}
105-
delete Browser.wgetRequests[handle];
106+
delete wget.wgetRequests[handle];
106107
};
107108

108109
// PROGRESS
109110
http.onprogress = function http_onprogress(e) {
110-
if (onprogress) Runtime.dynCall('viiii', onprogress, [handle, arg, e.loaded, e.lengthComputable || e.lengthComputable === undefined ? e.total : 0]);
111+
if (onprogress) dynCall('viiii', onprogress, [handle, arg, e.loaded, e.lengthComputable || e.lengthComputable === undefined ? e.total : 0]);
111112
};
112113

113114
// ABORT
114115
http.onabort = function http_onabort(e) {
115-
delete Browser.wgetRequests[handle];
116+
delete wget.wgetRequests[handle];
116117
};
117118

118119
// Useful because the browser can limit the number of redirection
@@ -132,7 +133,7 @@ mergeInto(LibraryManager.library, {
132133
http.send(null);
133134
}
134135

135-
Browser.wgetRequests[handle] = http;
136+
wget.wgetRequests[handle] = http;
136137

137138
return handle;
138139
},

0 commit comments

Comments
 (0)