From e86ec567f2eaccf8bba19db248014e33b7ce3909 Mon Sep 17 00:00:00 2001 From: witekfl Date: Sun, 4 Mar 2012 18:11:18 +0100 Subject: [PATCH] Compilation fixes (--enable-debug) --- src/scripting/smjs/action_object.c | 4 ++-- src/scripting/smjs/bookmarks.c | 9 +++++++-- src/scripting/smjs/elinks_object.c | 4 +++- src/scripting/smjs/globhist.c | 6 +++++- src/scripting/smjs/keybinding.c | 6 +++++- src/scripting/smjs/session_object.c | 4 +--- src/scripting/smjs/smjs.h | 3 +++ 7 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/scripting/smjs/action_object.c b/src/scripting/smjs/action_object.c index c816da3e..330e21f1 100644 --- a/src/scripting/smjs/action_object.c +++ b/src/scripting/smjs/action_object.c @@ -50,7 +50,7 @@ smjs_action_fn_callback(JSContext *ctx, uintN argc, jsval *rval) assert(smjs_ctx); if_assert_failed return JS_FALSE; - value = JS_FALSE; + value = JSVAL_FALSE; if (JS_TRUE != JS_ValueToObject(ctx, argv[-2], &fn_obj)) { JS_SET_RVAL(ctx, rval, value); @@ -76,7 +76,7 @@ smjs_action_fn_callback(JSContext *ctx, uintN argc, jsval *rval) do_action(hop->ses, hop->action_id, 1); - value = JS_TRUE; + value = JSVAL_TRUE; JS_SET_RVAL(ctx, rval, value); return JS_TRUE; diff --git a/src/scripting/smjs/bookmarks.c b/src/scripting/smjs/bookmarks.c index 9bc85ffc..bbca5b5d 100644 --- a/src/scripting/smjs/bookmarks.c +++ b/src/scripting/smjs/bookmarks.c @@ -186,6 +186,7 @@ static JSBool bookmark_set_property(JSContext *ctx, JSObject *obj, jsid id, JSBool strict, jsval *vp) { struct bookmark *bookmark; + jsid tmp; unsigned char *title = NULL; unsigned char *url = NULL; int ok; @@ -206,11 +207,15 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsid id, JSBool strict, jsv switch (JSID_TO_INT(id)) { case BOOKMARK_TITLE: - if (!jsval_to_bookmark_string(ctx, *vp, &title)) + if (!JS_ValueToId(ctx, *vp, &tmp)) + return JS_FALSE; + if (!jsval_to_bookmark_string(ctx, tmp, &title)) return JS_FALSE; break; case BOOKMARK_URL: - if (!jsval_to_bookmark_string(ctx, *vp, &url)) + if (!JS_ValueToId(ctx, *vp, &tmp)) + return JS_FALSE; + if (!jsval_to_bookmark_string(ctx, tmp, &url)) return JS_FALSE; break; default: diff --git a/src/scripting/smjs/elinks_object.c b/src/scripting/smjs/elinks_object.c index f7dd72bf..c06dc82e 100644 --- a/src/scripting/smjs/elinks_object.c +++ b/src/scripting/smjs/elinks_object.c @@ -4,6 +4,8 @@ #include "config.h" #endif +#include + #include "elinks.h" #include "bfu/msgbox.h" @@ -254,7 +256,7 @@ smjs_invoke_elinks_object_method(unsigned char *method, jsval argv[], int argc, method, rval)) return JS_FALSE; - if (JSVAL_VOID == *rval) + if (JSVAL_IS_VOID(*rval)) return JS_FALSE; return JS_CallFunctionValue(smjs_ctx, smjs_elinks_object, diff --git a/src/scripting/smjs/globhist.c b/src/scripting/smjs/globhist.c index 376c44ee..705e5f5f 100644 --- a/src/scripting/smjs/globhist.c +++ b/src/scripting/smjs/globhist.c @@ -206,8 +206,12 @@ smjs_globhist_get_property(JSContext *ctx, JSObject *obj, jsid id, jsval *vp) JSObject *jsobj; unsigned char *uri_string; struct global_history_item *history_item; + jsval tmp; - uri_string = JS_EncodeString(ctx, JS_ValueToString(ctx, id)); + if (!JS_IdToValue(ctx, id, &tmp)) + goto ret_null; + + uri_string = JS_EncodeString(ctx, JS_ValueToString(ctx, tmp)); if (!uri_string) goto ret_null; history_item = get_global_history_item(uri_string); diff --git a/src/scripting/smjs/keybinding.c b/src/scripting/smjs/keybinding.c index 4dbe7d7a..0ddf421b 100644 --- a/src/scripting/smjs/keybinding.c +++ b/src/scripting/smjs/keybinding.c @@ -22,6 +22,7 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsid id, jsval *vp) unsigned char *action_str; const unsigned char *keystroke_str; int *data; + jsval tmp; /* This can be called if @obj if not itself an instance of the * appropriate class but has one in its prototype chain. Fail @@ -32,7 +33,10 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsid id, jsval *vp) data = JS_GetInstancePrivate(ctx, obj, (JSClass *) &keymap_class, NULL); - keystroke_str = JS_EncodeString(ctx, JS_ValueToString(ctx, id)); + if (!JS_IdToValue(ctx, id, &tmp)) + goto ret_null; + + keystroke_str = JS_EncodeString(ctx, JS_ValueToString(ctx, tmp)); if (!keystroke_str) goto ret_null; action_str = get_action_name_from_keystroke((enum keymap_id) *data, diff --git a/src/scripting/smjs/session_object.c b/src/scripting/smjs/session_object.c index 933c545e..e03e66fc 100644 --- a/src/scripting/smjs/session_object.c +++ b/src/scripting/smjs/session_object.c @@ -454,7 +454,7 @@ session_construct(JSContext *ctx, uintN argc, jsval *rval) { jsval val; jsval *argv = JS_ARGV(ctx, rval); - int bg; /* open new tab in background */ + int bg = 0; /* open new tab in background */ struct session *ses; JSObject *jsobj; @@ -715,8 +715,6 @@ static const spidermonkeyFunctionSpec session_funcs[] = { void smjs_init_session_interface(void) { - JSObject *jsobj; - assert(smjs_ctx); assert(smjs_global_object); diff --git a/src/scripting/smjs/smjs.h b/src/scripting/smjs/smjs.h index ff8b957e..c7c5961a 100644 --- a/src/scripting/smjs/smjs.h +++ b/src/scripting/smjs/smjs.h @@ -5,6 +5,7 @@ struct module; struct cache_entry; struct session; struct terminal; +struct view_state; extern struct module smjs_scripting_module; @@ -18,4 +19,6 @@ void smjs_detach_session_object(struct session *ses); void smjs_detach_terminal_object(struct terminal *term); +void smjs_detach_view_state_object(struct view_state *vs); + #endif