1
0
Fork 0

[mujs] Compilation fixes

This commit is contained in:
Witold Filipczyk 2023-01-28 10:28:42 +01:00
parent c0e39a4f80
commit c058675c5d
5 changed files with 15 additions and 23 deletions

View File

@ -109,7 +109,7 @@ mjs_value_to_accesskey(const char *val)
#endif
if (*val) {
const char *end = strchr(val, '\0');
char *begin = val;
char *begin = (char *)val;
return utf8_to_unicode(&begin, end);
}

View File

@ -76,7 +76,7 @@ mjs_keyboardEvent_finalizer(js_State *J, void *val)
void
mjs_push_keyboardEvent(js_State *J, struct term_event *ev)
{
struct keyboard *keyb = mem_calloc(1, sizeof(*keyb));
struct keyboard *keyb = (struct keyboard *)mem_calloc(1, sizeof(*keyb));
if (!keyb) {
js_pushnull(J);

View File

@ -102,7 +102,7 @@ mjs_push_messageEvent(js_State *J, char *data, char *origin, char *source)
char id[32];
snprintf(id, "%d", 31, ++lastEventId);
snprintf(id, 31, "%d", ++lastEventId);
event->lastEventId = stracpy(id);
js_newobject(J);

View File

@ -48,18 +48,18 @@
struct listener {
LIST_HEAD(struct listener);
char *typ;
char *fun;
const char *fun;
};
struct el_window {
struct ecmascript_interpreter *interpreter;
char *thisval;
const char *thisval;
LIST_OF(struct listener) listeners;
char *onmessage;
};
struct el_message {
char *messageObject;
const char *messageObject;
struct el_window *elwin;
};
@ -227,7 +227,6 @@ mjs_window_clearTimeout(js_State *J)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
const char *text = js_tostring(J, 1);
int64_t number = atoll(text);
timer_id_T id = reinterpret_cast<timer_id_T>(number);
@ -489,7 +488,6 @@ mjs_window_removeEventListener(js_State *J)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
struct el_window *elwin = (struct el_window *)js_touserdata(J, 0, "window");
if (!elwin) {
@ -577,7 +575,6 @@ mjs_window_postMessage(js_State *J)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
struct el_window *elwin = (struct el_window *)js_touserdata(J, 0, "window");
const char *str = js_tostring(J, 1);
@ -605,7 +602,7 @@ mjs_window_postMessage(js_State *J)
mem_free_if(source);
js_pop(J, 1);
char *val = js_ref(J);
const char *val = js_ref(J);
struct el_message *mess = (struct el_message *)mem_calloc(1, sizeof(*mess));
if (!mess) {

View File

@ -109,7 +109,7 @@ struct classcomp {
struct listener {
LIST_HEAD(struct listener);
char *typ;
char *fun;
const char *fun;
};
struct mjs_xhr {
@ -485,11 +485,11 @@ mjs_xhr_open(js_State *J)
if (username || password) {
if (username) {
xhr->uri->user = username;
xhr->uri->user = (char *)username;
xhr->uri->userlen = strlen(username);
}
if (password) {
xhr->uri->password = password;
xhr->uri->password = (char *)password;
xhr->uri->passwordlen = strlen(password);
}
char *url2 = get_uri_string(xhr->uri, URI_DIR_LOCATION | URI_PATH | URI_USER | URI_PASSWORD);
@ -873,13 +873,13 @@ normalize(char *value)
}
static bool
valid_header(char *header)
valid_header(const char *header)
{
if (!*header) {
return false;
}
for (char *c = header; *c; c++) {
for (const char *c = header; *c; c++) {
if (*c < 33 || *c > 127) {
return false;
}
@ -888,7 +888,7 @@ valid_header(char *header)
}
static bool
forbidden_header(char *header)
forbidden_header(const char *header)
{
const char *bad[] = {
"Accept-Charset"
@ -938,12 +938,7 @@ mjs_xhr_setRequestHeader(js_State *J)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)js_getcontext(J);
struct mjs_xhr *xhr = (struct mjs_xhr *)js_touserdata(J, 0, "xhr");
struct view_state *vs;
struct document_view *doc_view;
vs = interpreter->vs;
doc_view = vs->doc_view;
if (!xhr) {
js_pushnull(J);
@ -960,7 +955,7 @@ mjs_xhr_setRequestHeader(js_State *J)
js_pushnull(J);
return;
}
const char *value = js_isundefined(J, 2) ? NULL : null_or_stracpy(js_tostring(J, 2));
char *value = js_isundefined(J, 2) ? NULL : null_or_stracpy(js_tostring(J, 2));
if (value) {
char *normalized_value = normalize(value);
@ -1541,7 +1536,7 @@ mjs_xhr_constructor(js_State *J)
addmethod(J, "getResponseHeader", mjs_xhr_getResponseHeader, 1);
addmethod(J, "open", mjs_xhr_open, 5);
addmethod(J, "overrideMimeType", mjs_xhr_overrideMimeType, 1);
addmethod(J, "removeEventListener", mjs_xhr_addEventListener, 3);
addmethod(J, "removeEventListener", mjs_xhr_removeEventListener, 3);
addmethod(J, "send", mjs_xhr_send, 1);
addmethod(J, "setRequestHeader", mjs_xhr_setRequestHeader, 2);