1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-29 03:17:53 -04:00

[quickjs] Compilation fixes

This commit is contained in:
Witold Filipczyk 2023-01-28 09:34:10 +01:00
parent 483796dc7f
commit 0e70bfb468
8 changed files with 14 additions and 25 deletions

View File

@ -342,7 +342,7 @@ void
render_xhtml_document(struct cache_entry *cached, struct document *document, struct string *buffer)
{
if (!document->dom) {
(void)get_convert_table(cached->head ?: "", document->options.cp,
(void)get_convert_table(cached->head ?: (char *)"", document->options.cp,
document->options.assume_cp,
&document->cp,
&document->cp_status,

View File

@ -86,9 +86,6 @@ js_attributes_set_items(JSContext *ctx, JSValue this_val, void *node)
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
assert(interpreter);
xmlpp::Element::AttributeList *al = static_cast<xmlpp::Element::AttributeList *>(node);
if (!al) {

View File

@ -41,9 +41,6 @@ js_console_log_common(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo
{
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
assert(interpreter);
if (argc != 1 || !log_filename)
{
return JS_UNDEFINED;

View File

@ -1153,7 +1153,6 @@ js_element_addEventListener(JSContext *ctx, JSValueConst this_val, int argc, JSV
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
struct js_element_private *el_private = (struct js_element_private *)(JS_GetOpaque(this_val, js_element_class_id));
if (!el_private) {
@ -1207,7 +1206,6 @@ js_element_removeEventListener(JSContext *ctx, JSValueConst this_val, int argc,
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
struct js_element_private *el_private = (struct js_element_private *)(JS_GetOpaque(this_val, js_element_class_id));
if (!el_private) {
@ -2172,7 +2170,7 @@ getElement(JSContext *ctx, void *node)
RETURN_JS(r);
}
struct js_element_private *el_private = mem_calloc(1, sizeof(*el_private));
struct js_element_private *el_private = (struct js_element_private *)mem_calloc(1, sizeof(*el_private));
if (!el_private) {
return JS_NULL;
@ -2200,7 +2198,6 @@ getElement(JSContext *ctx, void *node)
void
check_element_event(void *elem, const char *event_name, struct term_event *ev)
{
JSObject *obj;
auto el = map_privates.find(elem);
if (el == map_privates.end()) {

View File

@ -72,7 +72,7 @@ void js_keyboardEvent_finalizer(JSRuntime *rt, JSValue val)
{
REF_JS(val);
struct keyboard *keyb = JS_GetOpaque(val, js_keyboardEvent_class_id);
struct keyboard *keyb = (struct keyboard *)JS_GetOpaque(val, js_keyboardEvent_class_id);
if (keyb) {
mem_free(keyb);
@ -84,6 +84,7 @@ static JSClassDef js_keyboardEvent_class = {
js_keyboardEvent_finalizer
};
#if 0
static JSValue
js_keyboardEvent_ctor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv)
{
@ -122,6 +123,7 @@ fail:
mem_free(keyb);
return JS_EXCEPTION;
}
#endif
static const JSCFunctionListEntry js_keyboardEvent_proto_funcs[] = {
JS_CGETSET_DEF("key", js_keyboardEvent_get_property_key, nullptr),

View File

@ -94,6 +94,7 @@ static JSClassDef js_messageEvent_class = {
js_messageEvent_finalizer
};
#if 0
static JSValue
js_messageEvent_ctor(JSContext *ctx, JSValueConst new_target, int argc, JSValueConst *argv)
{
@ -134,6 +135,7 @@ fail:
mem_free(event);
return JS_EXCEPTION;
}
#endif
static const JSCFunctionListEntry js_messageEvent_proto_funcs[] = {
JS_CGETSET_DEF("data", js_messageEvent_get_property_data, nullptr),
@ -240,7 +242,7 @@ get_messageEvent(JSContext *ctx, char *data, char *origin, char *source)
char id[32];
snprintf(id, "%d", 31, ++lastEventId);
snprintf(id, 31, "%d", ++lastEventId);
event->lastEventId = stracpy(id);
JSValue event_obj = JS_NewObjectClass(ctx, js_messageEvent_class_id);

View File

@ -316,8 +316,6 @@ js_window_clearTimeout(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
if (argc != 1) {
return JS_UNDEFINED;
}
@ -592,7 +590,6 @@ js_window_removeEventListener(JSContext *ctx, JSValueConst this_val, int argc, J
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
struct el_window *elwin = (struct el_window *)(JS_GetOpaque(this_val, js_window_class_id));
if (!elwin) {
@ -685,7 +682,6 @@ js_window_postMessage(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo
#endif
REF_JS(this_val);
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
struct el_window *elwin = (struct el_window *)(JS_GetOpaque(this_val, js_window_class_id));
if (argc < 2) {
@ -737,12 +733,12 @@ static const JSCFunctionListEntry js_window_proto_funcs[] = {
JS_CGETSET_DEF("status", js_window_get_property_status, js_window_set_property_status),
JS_CGETSET_DEF("top", js_window_get_property_top, nullptr),
JS_CGETSET_DEF("window", js_window_get_property_self, nullptr),
JS_CFUNC_DEF("addEventListener", js_window_addEventListener, 3),
JS_CFUNC_DEF("addEventListener", 3, js_window_addEventListener),
JS_CFUNC_DEF("alert", 1, js_window_alert),
JS_CFUNC_DEF("clearTimeout", 1, js_window_clearTimeout),
JS_CFUNC_DEF("open", 3, js_window_open),
JS_CFUNC_DEF("postMessage", js_window_postMessage, 3),
JS_CFUNC_DEF("removeEventListener", js_window_removeEventListener, 3),
JS_CFUNC_DEF("postMessage", 3, js_window_postMessage),
JS_CFUNC_DEF("removeEventListener", 3, js_window_removeEventListener),
JS_CFUNC_DEF("setTimeout", 2, js_window_setTimeout),
JS_CFUNC_DEF("toString", 0, js_window_toString)
};

View File

@ -143,13 +143,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;
}
@ -158,7 +158,7 @@ valid_header(char *header)
}
static bool
forbidden_header(char *header)
forbidden_header(const char *header)
{
const char *bad[] = {
"Accept-Charset"
@ -1155,8 +1155,6 @@ xhr_open(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
#endif
REF_JS(this_val);
static const char head_method[] = "HEAD";
Xhr *x = xhr_get(ctx, this_val);
if (!x) {