1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-02 08:57:19 -04:00

Revert "Fix some issues with js."

This reverts commit 6322d2936a.
This commit is contained in:
Witold Filipczyk 2019-04-21 12:26:27 +02:00
parent 6322d2936a
commit 8d7112c27d
16 changed files with 226 additions and 294 deletions

View File

@ -88,6 +88,7 @@ jsid_to_string(JSContext *ctx, jsid *id)
} }
#define ELINKS_CAST_PROP_PARAMS JSObject *obj = (hobj); \ #define ELINKS_CAST_PROP_PARAMS JSObject *obj = (hobj); \
jsval vp = hvp; \ jsval vp2 = (hvp); \
jsval *vp = &vp2;
#endif #endif

View File

@ -85,11 +85,9 @@ document_get_property_cookie(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
strncpy(cookiestr, cookies->source, 1024); strncpy(cookiestr, cookies->source, 1024);
done_string(cookies); done_string(cookies);
string_to_jsval(ctx, &vp, cookiestr); string_to_jsval(ctx, vp, cookiestr);
hvp.set(vp);
} else { } else {
string_to_jsval(ctx, &vp, ""); string_to_jsval(ctx, vp, "");
hvp.set(vp);
} }
return JS_TRUE; return JS_TRUE;
@ -115,7 +113,7 @@ document_set_property_cookie(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
vs = JS_GetInstancePrivate(ctx, parent_win, vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL); &window_class, NULL);
set_cookie(vs->uri, jsval_to_string(ctx, &vp)); set_cookie(vs->uri, jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
} }
@ -137,7 +135,7 @@ document_get_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId h
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
if_assert_failed return JS_FALSE; if_assert_failed return JS_FALSE;
JS_GetProperty(ctx, parent_win, "location", &vp); JS_GetProperty(ctx, parent_win, "location", vp);
return JS_TRUE; return JS_TRUE;
} }
@ -164,7 +162,7 @@ document_set_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId h
vs = JS_GetInstancePrivate(ctx, parent_win, vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp)); location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
} }
@ -198,26 +196,22 @@ document_get_property_referrer(JSContext *ctx, JSHandleObject hobj, JSHandleId h
switch (get_opt_int("protocol.http.referer.policy", NULL)) { switch (get_opt_int("protocol.http.referer.policy", NULL)) {
case REFERER_NONE: case REFERER_NONE:
/* oh well */ /* oh well */
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
break; break;
case REFERER_FAKE: case REFERER_FAKE:
string_to_jsval(ctx, &vp, get_opt_str("protocol.http.referer.fake", NULL)); string_to_jsval(ctx, vp, get_opt_str("protocol.http.referer.fake", NULL));
hvp.set(vp);
break; break;
case REFERER_TRUE: case REFERER_TRUE:
/* XXX: Encode as in add_url_to_httset_prop_string(&prop, ) ? --pasky */ /* XXX: Encode as in add_url_to_httset_prop_string(&prop, ) ? --pasky */
if (ses->referrer) { if (ses->referrer) {
astring_to_jsval(ctx, &vp, get_uri_string(ses->referrer, URI_HTTP_REFERRER)); astring_to_jsval(ctx, vp, get_uri_string(ses->referrer, URI_HTTP_REFERRER));
hvp.set(vp);
} }
break; break;
case REFERER_SAME_URL: case REFERER_SAME_URL:
astring_to_jsval(ctx, &vp, get_uri_string(document->uri, URI_HTTP_REFERRER)); astring_to_jsval(ctx, vp, get_uri_string(document->uri, URI_HTTP_REFERRER));
hvp.set(vp);
break; break;
} }
@ -247,8 +241,7 @@ document_get_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
document = doc_view->document; document = doc_view->document;
string_to_jsval(ctx, &vp, document->title); string_to_jsval(ctx, vp, document->title);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -277,7 +270,7 @@ document_set_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
document = doc_view->document; document = doc_view->document;
mem_free_set(&document->title, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&document->title, stracpy(jsval_to_string(ctx, vp)));
print_screen_status(doc_view->session); print_screen_status(doc_view->session);
return JS_TRUE; return JS_TRUE;
@ -305,8 +298,7 @@ document_get_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
document = doc_view->document; document = doc_view->document;
astring_to_jsval(ctx, &vp, get_uri_string(document->uri, URI_ORIGINAL)); astring_to_jsval(ctx, vp, get_uri_string(document->uri, URI_ORIGINAL));
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -333,7 +325,7 @@ document_set_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
vs = JS_GetInstancePrivate(ctx, parent_win, vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp)); location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
} }
@ -386,8 +378,7 @@ document_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMut
if (!form->name || c_strcasecmp(string, form->name)) if (!form->name || c_strcasecmp(string, form->name))
continue; continue;
object_to_jsval(ctx, &vp, get_form_object(ctx, obj, find_form_view(doc_view, form))); object_to_jsval(ctx, vp, get_form_object(ctx, obj, find_form_view(doc_view, form)));
hvp.set(vp);
break; break;
} }

View File

@ -142,20 +142,16 @@ input_get_property_accessKey(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
/* Hiddens have no link. */ /* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
if (!link) return JS_TRUE; if (!link) return JS_TRUE;
if (!link->accesskey) { if (!link->accesskey) {
vp = JS_GetEmptyStringValue(ctx); *vp = JS_GetEmptyStringValue(ctx);
hvp.set(vp);
} else { } else {
keystr = unicode_to_jsstring(ctx, link->accesskey); keystr = unicode_to_jsstring(ctx, link->accesskey);
if (keystr) { if (keystr)
vp = STRING_TO_JSVAL(keystr); *vp = STRING_TO_JSVAL(keystr);
hvp.set(vp);
}
else else
return JS_FALSE; return JS_FALSE;
} }
@ -209,7 +205,7 @@ input_set_property_accessKey(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
/* Hiddens have no link. */ /* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
accesskey = jsval_to_accesskey(ctx, &vp); accesskey = jsval_to_accesskey(ctx, vp);
if (accesskey == UCS_NO_CHAR) if (accesskey == UCS_NO_CHAR)
return JS_FALSE; return JS_FALSE;
@ -262,8 +258,7 @@ input_get_property_alt(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
string_to_jsval(ctx, &vp, fc->alt); string_to_jsval(ctx, vp, fc->alt);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -308,7 +303,7 @@ input_set_property_alt(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE; return JS_TRUE;
} }
@ -329,8 +324,7 @@ input_get_property_checked(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
fs = input_get_form_state(ctx, obj); fs = input_get_form_state(ctx, obj);
if (!fs) return JS_FALSE; /* detached */ if (!fs) return JS_FALSE; /* detached */
boolean_to_jsval(ctx, &vp, fs->state); boolean_to_jsval(ctx, vp, fs->state);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -377,7 +371,7 @@ input_set_property_checked(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO) if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO)
return JS_TRUE; return JS_TRUE;
fs->state = jsval_to_boolean(ctx, &vp); fs->state = jsval_to_boolean(ctx, vp);
return JS_TRUE; return JS_TRUE;
} }
@ -425,8 +419,7 @@ input_get_property_defaultChecked(JSContext *ctx, JSHandleObject hobj, JSHandleI
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
boolean_to_jsval(ctx, &vp, fc->default_state); boolean_to_jsval(ctx, vp, fc->default_state);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -475,8 +468,7 @@ input_get_property_defaultValue(JSContext *ctx, JSHandleObject hobj, JSHandleId
assert(fc->form && fs); assert(fc->form && fs);
/* FIXME (bug 805): convert from the charset of the document */ /* FIXME (bug 805): convert from the charset of the document */
string_to_jsval(ctx, &vp, fc->default_value); string_to_jsval(ctx, vp, fc->default_value);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -525,8 +517,7 @@ input_get_property_disabled(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs); assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_DISABLED); boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_DISABLED);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -572,7 +563,7 @@ input_set_property_disabled(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs); assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_DISABLED fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_DISABLED
: fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY : fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY
: FORM_MODE_NORMAL); : FORM_MODE_NORMAL);
@ -596,8 +587,7 @@ input_get_property_form(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL));
if_assert_failed return JS_FALSE; if_assert_failed return JS_FALSE;
object_to_jsval(ctx, &vp, parent_form); object_to_jsval(ctx, vp, parent_form);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -645,8 +635,7 @@ input_get_property_maxLength(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
int_to_jsval(ctx, &vp, fc->maxlength); int_to_jsval(ctx, vp, fc->maxlength);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -691,7 +680,7 @@ input_set_property_maxLength(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
if (!JS_ValueToInt32(ctx, vp, &fc->maxlength)) if (!JS_ValueToInt32(ctx, *vp, &fc->maxlength))
return JS_FALSE; return JS_FALSE;
return JS_TRUE; return JS_TRUE;
@ -740,8 +729,7 @@ input_get_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
string_to_jsval(ctx, &vp, fc->name); string_to_jsval(ctx, vp, fc->name);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -787,7 +775,7 @@ input_set_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSB
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE; return JS_TRUE;
} }
@ -836,8 +824,7 @@ input_get_property_readonly(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs); assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_READONLY); boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_READONLY);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -884,7 +871,7 @@ input_set_property_readonly(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(fc->form && fs); assert(fc->form && fs);
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_READONLY fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_READONLY
: fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED : fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED
: FORM_MODE_NORMAL); : FORM_MODE_NORMAL);
@ -934,10 +921,9 @@ input_get_property_selectedIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (fc->type == FC_SELECT) int_to_jsval(ctx, &vp, fs->state); if (fc->type == FC_SELECT) int_to_jsval(ctx, vp, fs->state);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -986,7 +972,7 @@ input_set_property_selectedIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (fc->type == FC_SELECT) { if (fc->type == FC_SELECT) {
int item; int item;
if (!JS_ValueToInt32(ctx, vp, &item)) if (!JS_ValueToInt32(ctx, *vp, &item))
return JS_FALSE; return JS_FALSE;
if (item >= 0 && item < fc->nvalues) { if (item >= 0 && item < fc->nvalues) {
@ -1041,8 +1027,7 @@ input_get_property_size(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
assert(fc); assert(fc);
assert(fc->form && fs); assert(fc->form && fs);
int_to_jsval(ctx, &vp, fc->size); int_to_jsval(ctx, vp, fc->size);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1095,12 +1080,10 @@ input_get_property_src(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
/* Hiddens have no link. */ /* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (link && link->where_img) if (link && link->where_img)
string_to_jsval(ctx, &vp, link->where_img); string_to_jsval(ctx, vp, link->where_img);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1152,7 +1135,7 @@ input_set_property_src(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
if (link) { if (link) {
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, vp)));
} }
return JS_TRUE; return JS_TRUE;
@ -1207,13 +1190,11 @@ input_get_property_tabIndex(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
/* Hiddens have no link. */ /* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (link) if (link)
/* FIXME: This is WRONG. --pasky */ /* FIXME: This is WRONG. --pasky */
int_to_jsval(ctx, &vp, link->number); int_to_jsval(ctx, vp, link->number);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1276,8 +1257,7 @@ input_get_property_type(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
case FC_SELECT: s = "select"; break; case FC_SELECT: s = "select"; break;
default: INTERNAL("input_get_property() upon a non-input item."); break; default: INTERNAL("input_get_property() upon a non-input item."); break;
} }
string_to_jsval(ctx, &vp, s); string_to_jsval(ctx, vp, s);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1297,8 +1277,7 @@ input_get_property_value(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
fs = input_get_form_state(ctx, obj); fs = input_get_form_state(ctx, obj);
if (!fs) return JS_FALSE; /* detached */ if (!fs) return JS_FALSE; /* detached */
string_to_jsval(ctx, &vp, fs->value); string_to_jsval(ctx, vp, fs->value);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1344,7 +1323,7 @@ input_set_property_value(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(fc->form && fs); assert(fc->form && fs);
if (fc->type != FC_FILE) { if (fc->type != FC_FILE) {
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, vp)));
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD) if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
fs->state = strlen(fs->value); fs->state = strlen(fs->value);
} }
@ -1459,8 +1438,7 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
/* Hiddens have no link. */ /* Hiddens have no link. */
if (linknum >= 0) link = &document->links[linknum]; if (linknum >= 0) link = &document->links[linknum];
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case JSP_INPUT_ACCESSKEY: case JSP_INPUT_ACCESSKEY:
@ -1470,57 +1448,57 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
if (!link) break; if (!link) break;
if (!link->accesskey) { if (!link->accesskey) {
vp = JS_GetEmptyStringValue(ctx); *vp = JS_GetEmptyStringValue(ctx);
} else { } else {
keystr = unicode_to_jsstring(ctx, link->accesskey); keystr = unicode_to_jsstring(ctx, link->accesskey);
if (keystr) if (keystr)
vp = STRING_TO_JSVAL(keystr); *vp = STRING_TO_JSVAL(keystr);
else else
return JS_FALSE; return JS_FALSE;
} }
break; break;
} }
case JSP_INPUT_ALT: case JSP_INPUT_ALT:
string_to_jsval(ctx, &vp, fc->alt); string_to_jsval(ctx, vp, fc->alt);
break; break;
case JSP_INPUT_CHECKED: case JSP_INPUT_CHECKED:
boolean_to_jsval(ctx, &vp, fs->state); boolean_to_jsval(ctx, vp, fs->state);
break; break;
case JSP_INPUT_DEFAULT_CHECKED: case JSP_INPUT_DEFAULT_CHECKED:
boolean_to_jsval(ctx, &vp, fc->default_state); boolean_to_jsval(ctx, vp, fc->default_state);
break; break;
case JSP_INPUT_DEFAULT_VALUE: case JSP_INPUT_DEFAULT_VALUE:
/* FIXME (bug 805): convert from the charset of the document */ /* FIXME (bug 805): convert from the charset of the document */
string_to_jsval(ctx, &vp, fc->default_value); string_to_jsval(ctx, vp, fc->default_value);
break; break;
case JSP_INPUT_DISABLED: case JSP_INPUT_DISABLED:
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_DISABLED); boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_DISABLED);
break; break;
case JSP_INPUT_FORM: case JSP_INPUT_FORM:
object_to_jsval(ctx, &vp, parent_form); object_to_jsval(ctx, vp, parent_form);
break; break;
case JSP_INPUT_MAX_LENGTH: case JSP_INPUT_MAX_LENGTH:
int_to_jsval(ctx, &vp, fc->maxlength); int_to_jsval(ctx, vp, fc->maxlength);
break; break;
case JSP_INPUT_NAME: case JSP_INPUT_NAME:
string_to_jsval(ctx, &vp, fc->name); string_to_jsval(ctx, vp, fc->name);
break; break;
case JSP_INPUT_READONLY: case JSP_INPUT_READONLY:
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
boolean_to_jsval(ctx, &vp, fc->mode == FORM_MODE_READONLY); boolean_to_jsval(ctx, vp, fc->mode == FORM_MODE_READONLY);
break; break;
case JSP_INPUT_SIZE: case JSP_INPUT_SIZE:
int_to_jsval(ctx, &vp, fc->size); int_to_jsval(ctx, vp, fc->size);
break; break;
case JSP_INPUT_SRC: case JSP_INPUT_SRC:
if (link && link->where_img) if (link && link->where_img)
string_to_jsval(ctx, &vp, link->where_img); string_to_jsval(ctx, vp, link->where_img);
break; break;
case JSP_INPUT_TABINDEX: case JSP_INPUT_TABINDEX:
if (link) if (link)
/* FIXME: This is WRONG. --pasky */ /* FIXME: This is WRONG. --pasky */
int_to_jsval(ctx, &vp, link->number); int_to_jsval(ctx, vp, link->number);
break; break;
case JSP_INPUT_TYPE: case JSP_INPUT_TYPE:
{ {
@ -1540,15 +1518,15 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
case FC_SELECT: s = "select"; break; case FC_SELECT: s = "select"; break;
default: INTERNAL("input_get_property() upon a non-input item."); break; default: INTERNAL("input_get_property() upon a non-input item."); break;
} }
string_to_jsval(ctx, &vp, s); string_to_jsval(ctx, vp, s);
break; break;
} }
case JSP_INPUT_VALUE: case JSP_INPUT_VALUE:
string_to_jsval(ctx, &vp, fs->value); string_to_jsval(ctx, vp, fs->value);
break; break;
case JSP_INPUT_SELECTED_INDEX: case JSP_INPUT_SELECTED_INDEX:
if (fc->type == FC_SELECT) int_to_jsval(ctx, &vp, fs->state); if (fc->type == FC_SELECT) int_to_jsval(ctx, vp, fs->state);
break; break;
default: default:
/* Unrecognized integer property ID; someone is using /* Unrecognized integer property ID; someone is using
@ -1559,7 +1537,6 @@ input_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
* @undef_to_jsval.) */ * @undef_to_jsval.) */
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -1618,48 +1595,48 @@ input_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool s
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case JSP_INPUT_ACCESSKEY: case JSP_INPUT_ACCESSKEY:
accesskey = jsval_to_accesskey(ctx, &vp); accesskey = jsval_to_accesskey(ctx, vp);
if (accesskey == UCS_NO_CHAR) if (accesskey == UCS_NO_CHAR)
return JS_FALSE; return JS_FALSE;
else if (link) else if (link)
link->accesskey = accesskey; link->accesskey = accesskey;
break; break;
case JSP_INPUT_ALT: case JSP_INPUT_ALT:
mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fc->alt, stracpy(jsval_to_string(ctx, vp)));
break; break;
case JSP_INPUT_CHECKED: case JSP_INPUT_CHECKED:
if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO) if (fc->type != FC_CHECKBOX && fc->type != FC_RADIO)
break; break;
fs->state = jsval_to_boolean(ctx, &vp); fs->state = jsval_to_boolean(ctx, vp);
break; break;
case JSP_INPUT_DISABLED: case JSP_INPUT_DISABLED:
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_DISABLED fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_DISABLED
: fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY : fc->mode == FORM_MODE_READONLY ? FORM_MODE_READONLY
: FORM_MODE_NORMAL); : FORM_MODE_NORMAL);
break; break;
case JSP_INPUT_MAX_LENGTH: case JSP_INPUT_MAX_LENGTH:
if (!JS_ValueToInt32(ctx, vp, &fc->maxlength)) if (!JS_ValueToInt32(ctx, *vp, &fc->maxlength))
return JS_FALSE; return JS_FALSE;
break; break;
case JSP_INPUT_NAME: case JSP_INPUT_NAME:
mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fc->name, stracpy(jsval_to_string(ctx, vp)));
break; break;
case JSP_INPUT_READONLY: case JSP_INPUT_READONLY:
/* FIXME: <input readonly disabled> --pasky */ /* FIXME: <input readonly disabled> --pasky */
fc->mode = (jsval_to_boolean(ctx, &vp) ? FORM_MODE_READONLY fc->mode = (jsval_to_boolean(ctx, vp) ? FORM_MODE_READONLY
: fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED : fc->mode == FORM_MODE_DISABLED ? FORM_MODE_DISABLED
: FORM_MODE_NORMAL); : FORM_MODE_NORMAL);
break; break;
case JSP_INPUT_SRC: case JSP_INPUT_SRC:
if (link) { if (link) {
mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&link->where_img, stracpy(jsval_to_string(ctx, vp)));
} }
break; break;
case JSP_INPUT_VALUE: case JSP_INPUT_VALUE:
if (fc->type == FC_FILE) if (fc->type == FC_FILE)
break; /* A huge security risk otherwise. */ break; /* A huge security risk otherwise. */
mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&fs->value, stracpy(jsval_to_string(ctx, vp)));
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD) if (fc->type == FC_TEXT || fc->type == FC_PASSWORD)
fs->state = strlen(fs->value); fs->state = strlen(fs->value);
break; break;
@ -1667,7 +1644,7 @@ input_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool s
if (fc->type == FC_SELECT) { if (fc->type == FC_SELECT) {
int item; int item;
if (!JS_ValueToInt32(ctx, vp, &item)) if (!JS_ValueToInt32(ctx, *vp, &item))
return JS_FALSE; return JS_FALSE;
if (item >= 0 && item < fc->nvalues) { if (item >= 0 && item < fc->nvalues) {
@ -2013,27 +1990,25 @@ form_elements_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (JSID_IS_STRING(id)) { if (JSID_IS_STRING(id)) {
JS_IdToValue(ctx, id, &idval); JS_IdToValue(ctx, id, &idval);
form_elements_namedItem2(ctx, obj, 1, &idval, &vp); form_elements_namedItem2(ctx, obj, 1, &idval, vp);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_TRUE; return JS_TRUE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case JSP_FORM_ELEMENTS_LENGTH: case JSP_FORM_ELEMENTS_LENGTH:
int_to_jsval(ctx, &vp, list_size(&form->items)); int_to_jsval(ctx, vp, list_size(&form->items));
break; break;
default: default:
/* Array index. */ /* Array index. */
JS_IdToValue(ctx, id, &idval); JS_IdToValue(ctx, id, &idval);
form_elements_item2(ctx, obj, 1, &idval, &vp); form_elements_item2(ctx, obj, 1, &idval, vp);
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2075,8 +2050,7 @@ form_elements_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleI
if (!form_view) return JS_FALSE; /* detached */ if (!form_view) return JS_FALSE; /* detached */
form = find_form_by_form_view(document, form_view); form = find_form_by_form_view(document, form_view);
int_to_jsval(ctx, &vp, list_size(&form->items)); int_to_jsval(ctx, vp, list_size(&form->items));
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2349,27 +2323,26 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
&& (!fc->name || c_strcasecmp(string, fc->name))) && (!fc->name || c_strcasecmp(string, fc->name)))
continue; continue;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
fs = find_form_state(doc_view, fc); fs = find_form_state(doc_view, fc);
if (fs) { if (fs) {
fcobj = get_form_control_object(ctx, obj, fc->type, fs); fcobj = get_form_control_object(ctx, obj, fc->type, fs);
if (fcobj) if (fcobj)
object_to_jsval(ctx, &vp, fcobj); object_to_jsval(ctx, vp, fcobj);
} }
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_TRUE; return JS_TRUE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case JSP_FORM_ACTION: case JSP_FORM_ACTION:
string_to_jsval(ctx, &vp, form->action); string_to_jsval(ctx, vp, form->action);
break; break;
case JSP_FORM_ELEMENTS: case JSP_FORM_ELEMENTS:
@ -2380,7 +2353,7 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props); JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props);
spidermonkey_DefineFunctions(ctx, jsform_elems, spidermonkey_DefineFunctions(ctx, jsform_elems,
form_elements_funcs); form_elements_funcs);
object_to_jsval(ctx, &vp, jsform_elems); object_to_jsval(ctx, vp, jsform_elems);
/* SM will cache this property value for us so we create this /* SM will cache this property value for us so we create this
* just once per form. */ * just once per form. */
} }
@ -2390,41 +2363,41 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
switch (form->method) { switch (form->method) {
case FORM_METHOD_GET: case FORM_METHOD_GET:
case FORM_METHOD_POST: case FORM_METHOD_POST:
string_to_jsval(ctx, &vp, "application/x-www-form-urlencoded"); string_to_jsval(ctx, vp, "application/x-www-form-urlencoded");
break; break;
case FORM_METHOD_POST_MP: case FORM_METHOD_POST_MP:
string_to_jsval(ctx, &vp, "multipart/form-data"); string_to_jsval(ctx, vp, "multipart/form-data");
break; break;
case FORM_METHOD_POST_TEXT_PLAIN: case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "text/plain"); string_to_jsval(ctx, vp, "text/plain");
break; break;
} }
break; break;
case JSP_FORM_LENGTH: case JSP_FORM_LENGTH:
int_to_jsval(ctx, &vp, list_size(&form->items)); int_to_jsval(ctx, vp, list_size(&form->items));
break; break;
case JSP_FORM_METHOD: case JSP_FORM_METHOD:
switch (form->method) { switch (form->method) {
case FORM_METHOD_GET: case FORM_METHOD_GET:
string_to_jsval(ctx, &vp, "GET"); string_to_jsval(ctx, vp, "GET");
break; break;
case FORM_METHOD_POST: case FORM_METHOD_POST:
case FORM_METHOD_POST_MP: case FORM_METHOD_POST_MP:
case FORM_METHOD_POST_TEXT_PLAIN: case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "POST"); string_to_jsval(ctx, vp, "POST");
break; break;
} }
break; break;
case JSP_FORM_NAME: case JSP_FORM_NAME:
string_to_jsval(ctx, &vp, form->name); string_to_jsval(ctx, vp, form->name);
break; break;
case JSP_FORM_TARGET: case JSP_FORM_TARGET:
string_to_jsval(ctx, &vp, form->target); string_to_jsval(ctx, vp, form->target);
break; break;
default: default:
@ -2436,7 +2409,6 @@ form_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutable
* @undef_to_jsval.) */ * @undef_to_jsval.) */
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2474,8 +2446,7 @@ form_get_property_action(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv); form = find_form_by_form_view(doc_view->document, fv);
assert(form); assert(form);
string_to_jsval(ctx, &vp, form->action); string_to_jsval(ctx, vp, form->action);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2514,7 +2485,7 @@ form_set_property_action(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form); assert(form);
string = stracpy(jsval_to_string(ctx, &vp)); string = stracpy(jsval_to_string(ctx, vp));
if (form->action) { if (form->action) {
ecmascript_set_action(&form->action, string); ecmascript_set_action(&form->action, string);
} else { } else {
@ -2547,10 +2518,9 @@ form_get_property_elements(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props); JS_DefineProperties(ctx, jsform_elems, (JSPropertySpec *) form_elements_props);
spidermonkey_DefineFunctions(ctx, jsform_elems, spidermonkey_DefineFunctions(ctx, jsform_elems,
form_elements_funcs); form_elements_funcs);
object_to_jsval(ctx, &vp, jsform_elems); object_to_jsval(ctx, vp, jsform_elems);
/* SM will cache this property value for us so we create this /* SM will cache this property value for us so we create this
* just once per form. */ * just once per form. */
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2591,16 +2561,15 @@ form_get_property_encoding(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
switch (form->method) { switch (form->method) {
case FORM_METHOD_GET: case FORM_METHOD_GET:
case FORM_METHOD_POST: case FORM_METHOD_POST:
string_to_jsval(ctx, &vp, "application/x-www-form-urlencoded"); string_to_jsval(ctx, vp, "application/x-www-form-urlencoded");
break; break;
case FORM_METHOD_POST_MP: case FORM_METHOD_POST_MP:
string_to_jsval(ctx, &vp, "multipart/form-data"); string_to_jsval(ctx, vp, "multipart/form-data");
break; break;
case FORM_METHOD_POST_TEXT_PLAIN: case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "text/plain"); string_to_jsval(ctx, vp, "text/plain");
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2640,7 +2609,7 @@ form_set_property_encoding(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
assert(form); assert(form);
string = jsval_to_string(ctx, &vp); string = jsval_to_string(ctx, vp);
if (!c_strcasecmp(string, "application/x-www-form-urlencoded")) { if (!c_strcasecmp(string, "application/x-www-form-urlencoded")) {
form->method = form->method == FORM_METHOD_GET ? FORM_METHOD_GET form->method = form->method == FORM_METHOD_GET ? FORM_METHOD_GET
: FORM_METHOD_POST; : FORM_METHOD_POST;
@ -2686,8 +2655,7 @@ form_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form); assert(form);
int_to_jsval(ctx, &vp, list_size(&form->items)); int_to_jsval(ctx, vp, list_size(&form->items));
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2727,16 +2695,15 @@ form_get_property_method(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
switch (form->method) { switch (form->method) {
case FORM_METHOD_GET: case FORM_METHOD_GET:
string_to_jsval(ctx, &vp, "GET"); string_to_jsval(ctx, vp, "GET");
break; break;
case FORM_METHOD_POST: case FORM_METHOD_POST:
case FORM_METHOD_POST_MP: case FORM_METHOD_POST_MP:
case FORM_METHOD_POST_TEXT_PLAIN: case FORM_METHOD_POST_TEXT_PLAIN:
string_to_jsval(ctx, &vp, "POST"); string_to_jsval(ctx, vp, "POST");
break; break;
} }
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2776,7 +2743,7 @@ form_set_property_method(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
assert(form); assert(form);
string = jsval_to_string(ctx, &vp); string = jsval_to_string(ctx, vp);
if (!c_strcasecmp(string, "GET")) { if (!c_strcasecmp(string, "GET")) {
form->method = FORM_METHOD_GET; form->method = FORM_METHOD_GET;
} else if (!c_strcasecmp(string, "POST")) { } else if (!c_strcasecmp(string, "POST")) {
@ -2819,8 +2786,7 @@ form_get_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMu
assert(form); assert(form);
string_to_jsval(ctx, &vp, form->name); string_to_jsval(ctx, vp, form->name);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2858,7 +2824,7 @@ form_set_property_name(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBo
form = find_form_by_form_view(doc_view->document, fv); form = find_form_by_form_view(doc_view->document, fv);
assert(form); assert(form);
mem_free_set(&form->name, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&form->name, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE; return JS_TRUE;
} }
@ -2895,8 +2861,7 @@ form_get_property_target(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv); form = find_form_by_form_view(doc_view->document, fv);
assert(form); assert(form);
string_to_jsval(ctx, &vp, form->target); string_to_jsval(ctx, vp, form->target);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -2933,7 +2898,7 @@ form_set_property_target(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
form = find_form_by_form_view(doc_view->document, fv); form = find_form_by_form_view(doc_view->document, fv);
assert(form); assert(form);
mem_free_set(&form->target, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&form->target, stracpy(jsval_to_string(ctx, vp)));
return JS_TRUE; return JS_TRUE;
} }
@ -3195,16 +3160,14 @@ forms_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutabl
* we must leave *vp unchanged here, to avoid * we must leave *vp unchanged here, to avoid
* "TypeError: forms.namedItem is not a function". */ * "TypeError: forms.namedItem is not a function". */
JS_IdToValue(ctx, id, &idval); JS_IdToValue(ctx, id, &idval);
find_form_by_name(ctx, parent_doc, doc_view, idval, &vp); find_form_by_name(ctx, parent_doc, doc_view, idval, vp);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
} }
/* Array index. */ /* Array index. */
JS_IdToValue(ctx, id, &idval); JS_IdToValue(ctx, id, &idval);
forms_item2(ctx, obj, 1, &idval, &vp); forms_item2(ctx, obj, 1, &idval, vp);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -3238,8 +3201,7 @@ forms_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
document = doc_view->document; document = doc_view->document;
int_to_jsval(ctx, &vp, list_size(&document->forms)); int_to_jsval(ctx, vp, list_size(&document->forms));
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }

View File

@ -173,8 +173,7 @@ location_get_property_href(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, parent_win, vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL); &window_class, NULL);
astring_to_jsval(ctx, &vp, get_uri_string(vs->uri, URI_ORIGINAL)); astring_to_jsval(ctx, vp, get_uri_string(vs->uri, URI_ORIGINAL));
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -199,7 +198,7 @@ location_set_property_href(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, parent_win, vs = JS_GetInstancePrivate(ctx, parent_win,
&window_class, NULL); &window_class, NULL);
doc_view = vs->doc_view; doc_view = vs->doc_view;
location_goto(doc_view, jsval_to_string(ctx, &vp)); location_goto(doc_view, jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
} }

View File

@ -92,8 +92,7 @@ navigator_get_property_appCodeName(JSContext *ctx, JSHandleObject hobj, JSHandle
ELINKS_CAST_PROP_PARAMS ELINKS_CAST_PROP_PARAMS
(void)obj; (void)obj;
string_to_jsval(ctx, &vp, "Mozilla"); /* More like a constant nowadays. */ string_to_jsval(ctx, vp, "Mozilla"); /* More like a constant nowadays. */
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -104,8 +103,7 @@ navigator_get_property_appName(JSContext *ctx, JSHandleObject hobj, JSHandleId h
ELINKS_CAST_PROP_PARAMS ELINKS_CAST_PROP_PARAMS
(void)obj; (void)obj;
string_to_jsval(ctx, &vp, "ELinks (roughly compatible with Netscape Navigator, Mozilla and Microsoft Internet Explorer)"); string_to_jsval(ctx, vp, "ELinks (roughly compatible with Netscape Navigator, Mozilla and Microsoft Internet Explorer)");
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -116,8 +114,7 @@ navigator_get_property_appVersion(JSContext *ctx, JSHandleObject hobj, JSHandleI
ELINKS_CAST_PROP_PARAMS ELINKS_CAST_PROP_PARAMS
(void)obj; (void)obj;
string_to_jsval(ctx, &vp, VERSION); string_to_jsval(ctx, vp, VERSION);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -128,14 +125,12 @@ navigator_get_property_language(JSContext *ctx, JSHandleObject hobj, JSHandleId
ELINKS_CAST_PROP_PARAMS ELINKS_CAST_PROP_PARAMS
(void)obj; (void)obj;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
#ifdef CONFIG_NLS #ifdef CONFIG_NLS
if (get_opt_bool("protocol.http.accept_ui_language", NULL)) if (get_opt_bool("protocol.http.accept_ui_language", NULL))
string_to_jsval(ctx, &vp, language_to_iso639(current_language)); string_to_jsval(ctx, vp, language_to_iso639(current_language));
#endif #endif
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -145,8 +140,7 @@ navigator_get_property_platform(JSContext *ctx, JSHandleObject hobj, JSHandleId
ELINKS_CAST_PROP_PARAMS ELINKS_CAST_PROP_PARAMS
(void)obj; (void)obj;
string_to_jsval(ctx, &vp, system_name); string_to_jsval(ctx, vp, system_name);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -179,14 +173,12 @@ navigator_get_property_userAgent(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (ustr) { if (ustr) {
safe_strncpy(custr, ustr, 256); safe_strncpy(custr, ustr, 256);
mem_free(ustr); mem_free(ustr);
string_to_jsval(ctx, &vp, custr); string_to_jsval(ctx, vp, custr);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
} }
string_to_jsval(ctx, &vp, system_name); string_to_jsval(ctx, vp, system_name);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }

View File

@ -106,7 +106,7 @@ unibar_get_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
bar = JS_GetPrivate(obj); /* from @menubar_class or @statusbar_class */ bar = JS_GetPrivate(obj); /* from @menubar_class or @statusbar_class */
#define unibar_fetch(bar) \ #define unibar_fetch(bar) \
boolean_to_jsval(ctx, &vp, status->force_show_##bar##_bar >= 0 \ boolean_to_jsval(ctx, vp, status->force_show_##bar##_bar >= 0 \
? status->force_show_##bar##_bar \ ? status->force_show_##bar##_bar \
: status->show_##bar##_bar) : status->show_##bar##_bar)
switch (*bar) { switch (*bar) {
@ -117,11 +117,10 @@ unibar_get_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
unibar_fetch(title); unibar_fetch(title);
break; break;
default: default:
boolean_to_jsval(ctx, &vp, 0); boolean_to_jsval(ctx, vp, 0);
break; break;
} }
#undef unibar_fetch #undef unibar_fetch
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -155,10 +154,10 @@ unibar_set_property_visible(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
switch (*bar) { switch (*bar) {
case 's': case 's':
status->force_show_status_bar = jsval_to_boolean(ctx, &vp); status->force_show_status_bar = jsval_to_boolean(ctx, vp);
break; break;
case 't': case 't':
status->force_show_title_bar = jsval_to_boolean(ctx, &vp); status->force_show_title_bar = jsval_to_boolean(ctx, vp);
break; break;
default: default:
break; break;

View File

@ -153,8 +153,7 @@ window_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
/* TODO: Try other lookups (mainly element lookup) until /* TODO: Try other lookups (mainly element lookup) until
* something yields data. */ * something yields data. */
if (obj) { if (obj) {
object_to_jsval(ctx, &vp, obj); object_to_jsval(ctx, vp, obj);
hvp.set(vp);
} }
return JS_TRUE; return JS_TRUE;
} }
@ -162,20 +161,17 @@ window_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_TRUE; return JS_TRUE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case JSP_WIN_CLOSED: case JSP_WIN_CLOSED:
/* TODO: It will be a major PITA to implement this properly. /* TODO: It will be a major PITA to implement this properly.
* Well, perhaps not so much if we introduce reference tracking * Well, perhaps not so much if we introduce reference tracking
* for (struct session)? Still... --pasky */ * for (struct session)? Still... --pasky */
boolean_to_jsval(ctx, &vp, 0); boolean_to_jsval(ctx, vp, 0);
hvp.set(vp);
break; break;
case JSP_WIN_SELF: case JSP_WIN_SELF:
object_to_jsval(ctx, &vp, obj); object_to_jsval(ctx, vp, obj);
hvp.set(vp);
break; break;
case JSP_WIN_PARENT: case JSP_WIN_PARENT:
/* XXX: It would be nice if the following worked, yes. /* XXX: It would be nice if the following worked, yes.
@ -215,8 +211,7 @@ found_parent:
if (doc_view->vs.ecmascript_fragile) if (doc_view->vs.ecmascript_fragile)
ecmascript_reset_state(&doc_view->vs); ecmascript_reset_state(&doc_view->vs);
assert(doc_view->ecmascript); assert(doc_view->ecmascript);
object_to_jsval(ctx, &vp, JS_GetGlobalObject(doc_view->ecmascript->backend_data)); object_to_jsval(ctx, vp, JS_GetGlobalObject(doc_view->ecmascript->backend_data));
hvp.set(vp);
break; break;
} }
#endif #endif
@ -242,8 +237,7 @@ found_parent:
* let the script walk thru. That'd mean moving the check to * let the script walk thru. That'd mean moving the check to
* other individual properties in this switch. */ * other individual properties in this switch. */
if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST)) if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST))
object_to_jsval(ctx, &vp, newjsframe); object_to_jsval(ctx, vp, newjsframe);
hvp.set(vp);
/* else */ /* else */
/****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\ /****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\
|* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *| |* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *|
@ -455,8 +449,7 @@ window_get_property_closed(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!JS_InstanceOf(ctx, obj, &window_class, NULL)) if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE; return JS_FALSE;
boolean_to_jsval(ctx, &vp, 0); boolean_to_jsval(ctx, vp, 0);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -483,8 +476,7 @@ window_get_property_parent(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
* INCORRECT but works for the most common cases of just two * INCORRECT but works for the most common cases of just two
* frames. Better something than nothing. */ * frames. Better something than nothing. */
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -500,8 +492,7 @@ window_get_property_self(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
if (!JS_InstanceOf(ctx, obj, &window_class, NULL)) if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE; return JS_FALSE;
object_to_jsval(ctx, &vp, obj); object_to_jsval(ctx, vp, obj);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -517,8 +508,7 @@ window_get_property_status(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!JS_InstanceOf(ctx, obj, &window_class, NULL)) if (!JS_InstanceOf(ctx, obj, &window_class, NULL))
return JS_FALSE; return JS_FALSE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
return JS_TRUE; return JS_TRUE;
} }
@ -538,7 +528,7 @@ window_set_property_status(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs = JS_GetInstancePrivate(ctx, obj, &window_class, NULL); vs = JS_GetInstancePrivate(ctx, obj, &window_class, NULL);
mem_free_set(&vs->doc_view->session->status.window_status, stracpy(jsval_to_string(ctx, &vp))); mem_free_set(&vs->doc_view->session->status.window_status, stracpy(jsval_to_string(ctx, vp)));
print_screen_status(vs->doc_view->session); print_screen_status(vs->doc_view->session);
return JS_TRUE; return JS_TRUE;
@ -564,8 +554,7 @@ window_get_property_top(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
doc_view = vs->doc_view; doc_view = vs->doc_view;
top_view = doc_view->session->doc_view; top_view = doc_view->session->doc_view;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
hvp.set(vp);
assert(top_view && top_view->vs); assert(top_view && top_view->vs);
if (top_view->vs->ecmascript_fragile) if (top_view->vs->ecmascript_fragile)
@ -581,8 +570,7 @@ window_get_property_top(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
* let the script walk thru. That'd mean moving the check to * let the script walk thru. That'd mean moving the check to
* other individual properties in this switch. */ * other individual properties in this switch. */
if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST)) if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST))
object_to_jsval(ctx, &vp, newjsframe); object_to_jsval(ctx, vp, newjsframe);
hvp.set(vp);
/* else */ /* else */
/****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\ /****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\
|* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *| |* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *|

View File

@ -174,7 +174,7 @@ action_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
JSObject *action_fn; JSObject *action_fn;
unsigned char *action_str; unsigned char *action_str;
vp = JSVAL_NULL; *vp = JSVAL_NULL;
JS_IdToValue(ctx, id, &val); JS_IdToValue(ctx, id, &val);
action_str = JS_EncodeString(ctx, JS_ValueToString(ctx, val)); action_str = JS_EncodeString(ctx, JS_ValueToString(ctx, val));
@ -183,7 +183,7 @@ action_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
action_fn = smjs_get_action_fn_object(action_str); action_fn = smjs_get_action_fn_object(action_str);
if (!action_fn) return JS_TRUE; if (!action_fn) return JS_TRUE;
vp = OBJECT_TO_JSVAL(action_fn); *vp = OBJECT_TO_JSVAL(action_fn);
return JS_TRUE; return JS_TRUE;
} }

View File

@ -183,7 +183,7 @@ bookmark_get_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!bookmark) return JS_FALSE; if (!bookmark) return JS_FALSE;
return bookmark_string_to_jsval(ctx, bookmark->title, &vp); return bookmark_string_to_jsval(ctx, bookmark->title, vp);
} }
static JSBool static JSBool
@ -207,7 +207,7 @@ bookmark_set_property_title(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if (!bookmark) return JS_FALSE; if (!bookmark) return JS_FALSE;
if (!jsval_to_bookmark_string(ctx, vp, &title)) if (!jsval_to_bookmark_string(ctx, *vp, &title))
return JS_FALSE; return JS_FALSE;
ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url); ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url);
@ -234,7 +234,7 @@ bookmark_get_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
if (!bookmark) return JS_FALSE; if (!bookmark) return JS_FALSE;
return bookmark_string_to_jsval(ctx, bookmark->url, &vp); return bookmark_string_to_jsval(ctx, bookmark->url, vp);
} }
static JSBool static JSBool
@ -258,7 +258,7 @@ bookmark_set_property_url(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, J
if (!bookmark) return JS_FALSE; if (!bookmark) return JS_FALSE;
if (!jsval_to_bookmark_string(ctx, vp, &url)) if (!jsval_to_bookmark_string(ctx, *vp, &url))
return JS_FALSE; return JS_FALSE;
ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url); ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url);
@ -285,7 +285,7 @@ bookmark_get_property_children(JSContext *ctx, JSHandleObject hobj, JSHandleId h
if (!bookmark) return JS_FALSE; if (!bookmark) return JS_FALSE;
vp = OBJECT_TO_JSVAL(smjs_get_bookmark_folder_object(bookmark)); *vp = OBJECT_TO_JSVAL(smjs_get_bookmark_folder_object(bookmark));
return JS_TRUE; return JS_TRUE;
} }
@ -331,7 +331,7 @@ bookmark_folder_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
folder = JS_GetInstancePrivate(ctx, obj, folder = JS_GetInstancePrivate(ctx, obj,
(JSClass *) &bookmark_folder_class, NULL); (JSClass *) &bookmark_folder_class, NULL);
vp = JSVAL_NULL; *vp = JSVAL_NULL;
if (!JS_IdToValue(ctx, id, &title_jsval)) if (!JS_IdToValue(ctx, id, &title_jsval))
return JS_FALSE; return JS_FALSE;
@ -341,7 +341,7 @@ bookmark_folder_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
bookmark = get_bookmark_by_name(folder, title); bookmark = get_bookmark_by_name(folder, title);
if (bookmark) { if (bookmark) {
vp = OBJECT_TO_JSVAL(smjs_get_bookmark_object(bookmark)); *vp = OBJECT_TO_JSVAL(smjs_get_bookmark_object(bookmark));
} }
mem_free(title); mem_free(title);

View File

@ -83,13 +83,13 @@ cache_entry_get_property_content(JSContext *ctx, JSHandleObject hobj, JSHandleId
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
fragment = get_cache_fragment(cached); fragment = get_cache_fragment(cached);
if (!fragment) { if (!fragment) {
ret = JS_FALSE; ret = JS_FALSE;
} else { } else {
vp = STRING_TO_JSVAL(JS_NewStringCopyN(smjs_ctx, fragment->data, fragment->length)); *vp = STRING_TO_JSVAL(JS_NewStringCopyN(smjs_ctx, fragment->data, fragment->length));
ret = JS_TRUE; ret = JS_TRUE;
} }
@ -126,7 +126,7 @@ cache_entry_set_property_content(JSContext *ctx, JSHandleObject hobj, JSHandleId
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
str = JS_EncodeString(smjs_ctx, jsstr); str = JS_EncodeString(smjs_ctx, jsstr);
len = JS_GetStringLength(jsstr); len = JS_GetStringLength(jsstr);
add_fragment(cached, 0, str, len); add_fragment(cached, 0, str, len);
@ -161,7 +161,7 @@ cache_entry_get_property_type(JSContext *ctx, JSHandleObject hobj, JSHandleId hi
* collect garbage. After this, all code paths must * collect garbage. After this, all code paths must
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, cached->content_type)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, cached->content_type));
object_unlock(cached); object_unlock(cached);
return JS_TRUE; return JS_TRUE;
@ -195,7 +195,7 @@ cache_entry_set_property_type(JSContext *ctx, JSHandleObject hobj, JSHandleId hi
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
str = JS_EncodeString(smjs_ctx, jsstr); str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&cached->content_type, stracpy(str)); mem_free_set(&cached->content_type, stracpy(str));
@ -313,7 +313,7 @@ cache_entry_get_property_length(JSContext *ctx, JSHandleObject hobj, JSHandleId
* collect garbage. After this, all code paths must * collect garbage. After this, all code paths must
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
vp = INT_TO_JSVAL(cached->length); *vp = INT_TO_JSVAL(cached->length);
object_unlock(cached); object_unlock(cached);
return JS_TRUE; return JS_TRUE;
@ -344,7 +344,7 @@ cache_entry_get_property_head(JSContext *ctx, JSHandleObject hobj, JSHandleId hi
* collect garbage. After this, all code paths must * collect garbage. After this, all code paths must
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, cached->head)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, cached->head));
object_unlock(cached); object_unlock(cached);
return JS_TRUE; return JS_TRUE;
@ -378,7 +378,7 @@ cache_entry_set_property_head(JSContext *ctx, JSHandleObject hobj, JSHandleId hi
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
str = JS_EncodeString(smjs_ctx, jsstr); str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&cached->head, stracpy(str)); mem_free_set(&cached->head, stracpy(str));
@ -412,7 +412,7 @@ cache_entry_get_property_uri(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
* collect garbage. After this, all code paths must * collect garbage. After this, all code paths must
* eventually unlock the object. */ * eventually unlock the object. */
object_lock(cached); object_lock(cached);
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, struri(cached->uri))); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, struri(cached->uri)));
object_unlock(cached); object_unlock(cached);
return JS_TRUE; return JS_TRUE;

View File

@ -137,11 +137,11 @@ elinks_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
return JS_TRUE; return JS_TRUE;
} }
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case ELINKS_HOME: case ELINKS_HOME:
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, elinks_home)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, elinks_home));
return JS_TRUE; return JS_TRUE;
case ELINKS_LOCATION: { case ELINKS_LOCATION: {
@ -152,7 +152,7 @@ elinks_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
uri = have_location(smjs_ses) ? cur_loc(smjs_ses)->vs.uri uri = have_location(smjs_ses) ? cur_loc(smjs_ses)->vs.uri
: smjs_ses->loading_uri; : smjs_ses->loading_uri;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx,
uri ? (const char *) struri(uri) : "")); uri ? (const char *) struri(uri) : ""));
return JS_TRUE; return JS_TRUE;
@ -165,7 +165,7 @@ elinks_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
jsobj = smjs_get_session_object(smjs_ses); jsobj = smjs_get_session_object(smjs_ses);
if (!jsobj) return JS_FALSE; if (!jsobj) return JS_FALSE;
object_to_jsval(ctx, &vp, jsobj); object_to_jsval(ctx, vp, jsobj);
return JS_TRUE; return JS_TRUE;
} }
@ -202,7 +202,7 @@ elinks_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
if (!smjs_ses) return JS_FALSE; if (!smjs_ses) return JS_FALSE;
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
if (!jsstr) return JS_FALSE; if (!jsstr) return JS_FALSE;
url = JS_EncodeString(smjs_ctx, jsstr); url = JS_EncodeString(smjs_ctx, jsstr);
@ -287,7 +287,7 @@ elinks_get_property_home(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JS
if (!JS_InstanceOf(ctx, obj, (JSClass *) &elinks_class, NULL)) if (!JS_InstanceOf(ctx, obj, (JSClass *) &elinks_class, NULL))
return JS_FALSE; return JS_FALSE;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, elinks_home)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, elinks_home));
return JS_TRUE; return JS_TRUE;
} }
@ -307,7 +307,7 @@ elinks_get_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
if (!smjs_ses) return JS_FALSE; if (!smjs_ses) return JS_FALSE;
uri = have_location(smjs_ses) ? cur_loc(smjs_ses)->vs.uri : smjs_ses->loading_uri; uri = have_location(smjs_ses) ? cur_loc(smjs_ses)->vs.uri : smjs_ses->loading_uri;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, uri ? (const char *) struri(uri) : "")); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, uri ? (const char *) struri(uri) : ""));
return JS_TRUE; return JS_TRUE;
} }
@ -327,7 +327,7 @@ elinks_set_property_location(JSContext *ctx, JSHandleObject hobj, JSHandleId hid
if (!smjs_ses) return JS_FALSE; if (!smjs_ses) return JS_FALSE;
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
if (!jsstr) return JS_FALSE; if (!jsstr) return JS_FALSE;
url = JS_EncodeString(smjs_ctx, jsstr); url = JS_EncodeString(smjs_ctx, jsstr);
@ -355,7 +355,7 @@ elinks_get_property_session(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
jsobj = smjs_get_session_object(smjs_ses); jsobj = smjs_get_session_object(smjs_ses);
if (!jsobj) return JS_FALSE; if (!jsobj) return JS_FALSE;
object_to_jsval(ctx, &vp, jsobj); object_to_jsval(ctx, vp, jsobj);
return JS_TRUE; return JS_TRUE;
} }

View File

@ -94,19 +94,19 @@ smjs_globhist_item_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_FALSE; return JS_FALSE;
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case GLOBHIST_TITLE: case GLOBHIST_TITLE:
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx,
history_item->title)); history_item->title));
return JS_TRUE; return JS_TRUE;
case GLOBHIST_URL: case GLOBHIST_URL:
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx,
history_item->url)); history_item->url));
return JS_TRUE; return JS_TRUE;
@ -127,7 +127,7 @@ smjs_globhist_item_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
* Since the Date object uses milliseconds since the epoch, * Since the Date object uses milliseconds since the epoch,
* I'd rather export that, but SpiderMonkey doesn't provide * I'd rather export that, but SpiderMonkey doesn't provide
* a suitable type. -- Miciah */ * a suitable type. -- Miciah */
vp = JS_NumberValue(history_item->last_visit); *vp = JS_NumberValue(history_item->last_visit);
return JS_TRUE; return JS_TRUE;
default: default:
@ -167,7 +167,7 @@ smjs_globhist_item_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case GLOBHIST_TITLE: { case GLOBHIST_TITLE: {
JSString *jsstr = JS_ValueToString(smjs_ctx, vp); JSString *jsstr = JS_ValueToString(smjs_ctx, *vp);
unsigned char *str = JS_EncodeString(smjs_ctx, jsstr); unsigned char *str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&history_item->title, stracpy(str)); mem_free_set(&history_item->title, stracpy(str));
@ -175,7 +175,7 @@ smjs_globhist_item_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
return JS_TRUE; return JS_TRUE;
} }
case GLOBHIST_URL: { case GLOBHIST_URL: {
JSString *jsstr = JS_ValueToString(smjs_ctx, vp); JSString *jsstr = JS_ValueToString(smjs_ctx, *vp);
unsigned char *str = JS_EncodeString(smjs_ctx, jsstr); unsigned char *str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&history_item->url, stracpy(str)); mem_free_set(&history_item->url, stracpy(str));
@ -186,7 +186,7 @@ smjs_globhist_item_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
uint32_t seconds; uint32_t seconds;
/* Bug 923: Assumes time_t values fit in uint32. */ /* Bug 923: Assumes time_t values fit in uint32. */
JS_ValueToECMAUint32(smjs_ctx, vp, &seconds); JS_ValueToECMAUint32(smjs_ctx, *vp, &seconds);
history_item->last_visit = seconds; history_item->last_visit = seconds;
return JS_TRUE; return JS_TRUE;
@ -245,12 +245,12 @@ smjs_globhist_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
jsobj = smjs_get_globhist_item_object(history_item); jsobj = smjs_get_globhist_item_object(history_item);
if (!jsobj) goto ret_null; if (!jsobj) goto ret_null;
vp = OBJECT_TO_JSVAL(jsobj); *vp = OBJECT_TO_JSVAL(jsobj);
return JS_TRUE; return JS_TRUE;
ret_null: ret_null:
vp = JSVAL_NULL; *vp = JSVAL_NULL;
return JS_TRUE; return JS_TRUE;
} }
@ -305,7 +305,7 @@ smjs_globhist_item_get_property_title(JSContext *ctx, JSHandleObject hobj, JSHan
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, history_item->title)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, history_item->title));
return JS_TRUE; return JS_TRUE;
} }
@ -331,7 +331,7 @@ smjs_globhist_item_set_property_title(JSContext *ctx, JSHandleObject hobj, JSHan
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
str = JS_EncodeString(smjs_ctx, jsstr); str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&history_item->title, stracpy(str)); mem_free_set(&history_item->title, stracpy(str));
@ -358,7 +358,7 @@ smjs_globhist_item_get_property_url(JSContext *ctx, JSHandleObject hobj, JSHandl
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, history_item->url)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, history_item->url));
return JS_TRUE; return JS_TRUE;
} }
@ -384,7 +384,7 @@ smjs_globhist_item_set_property_url(JSContext *ctx, JSHandleObject hobj, JSHandl
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
jsstr = JS_ValueToString(smjs_ctx, vp); jsstr = JS_ValueToString(smjs_ctx, *vp);
str = JS_EncodeString(smjs_ctx, jsstr); str = JS_EncodeString(smjs_ctx, jsstr);
mem_free_set(&history_item->url, stracpy(str)); mem_free_set(&history_item->url, stracpy(str));
@ -427,7 +427,7 @@ smjs_globhist_item_get_property_last_visit(JSContext *ctx, JSHandleObject hobj,
* Since the Date object uses milliseconds since the epoch, * Since the Date object uses milliseconds since the epoch,
* I'd rather export that, but SpiderMonkey doesn't provide * I'd rather export that, but SpiderMonkey doesn't provide
* a suitable type. -- Miciah */ * a suitable type. -- Miciah */
vp = JS_NumberValue(history_item->last_visit); *vp = JS_NumberValue(history_item->last_visit);
return JS_TRUE; return JS_TRUE;
} }
@ -454,7 +454,7 @@ smjs_globhist_item_set_property_last_visit(JSContext *ctx, JSHandleObject hobj,
if (!history_item) return JS_FALSE; if (!history_item) return JS_FALSE;
/* Bug 923: Assumes time_t values fit in uint32. */ /* Bug 923: Assumes time_t values fit in uint32. */
JS_ValueToECMAUint32(smjs_ctx, vp, &seconds); JS_ValueToECMAUint32(smjs_ctx, *vp, &seconds);
history_item->last_visit = seconds; history_item->last_visit = seconds;
return JS_TRUE; return JS_TRUE;

View File

@ -56,12 +56,12 @@ keymap_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMutab
keystroke_str); keystroke_str);
if (!action_str || !strcmp(action_str, "none")) goto ret_null; if (!action_str || !strcmp(action_str, "none")) goto ret_null;
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(ctx, action_str)); *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(ctx, action_str));
return JS_TRUE; return JS_TRUE;
ret_null: ret_null:
vp = JSVAL_NULL; *vp = JSVAL_NULL;
return JS_TRUE; return JS_TRUE;
} }
@ -115,10 +115,10 @@ keymap_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
keystroke_str = JS_EncodeString(ctx, JS_ValueToString(ctx, val)); keystroke_str = JS_EncodeString(ctx, JS_ValueToString(ctx, val));
if (!keystroke_str) return JS_FALSE; if (!keystroke_str) return JS_FALSE;
if (JSVAL_IS_STRING(vp)) { if (JSVAL_IS_STRING(*vp)) {
unsigned char *action_str; unsigned char *action_str;
action_str = JS_EncodeString(ctx, JS_ValueToString(ctx, vp)); action_str = JS_EncodeString(ctx, JS_ValueToString(ctx, *vp));
if (!action_str) return JS_FALSE; if (!action_str) return JS_FALSE;
if (bind_do(keymap_str, keystroke_str, action_str, 0)) if (bind_do(keymap_str, keystroke_str, action_str, 0))
@ -126,17 +126,17 @@ keymap_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
return JS_TRUE; return JS_TRUE;
} else if (JSVAL_IS_NULL(vp)) { /* before JSVAL_IS_OBJECT */ } else if (JSVAL_IS_NULL(*vp)) { /* before JSVAL_IS_OBJECT */
if (bind_do(keymap_str, keystroke_str, "none", 0)) if (bind_do(keymap_str, keystroke_str, "none", 0))
return JS_FALSE; return JS_FALSE;
return JS_TRUE; return JS_TRUE;
} else if (!JSVAL_IS_PRIMITIVE(vp) || JSVAL_IS_NULL(vp)) { } else if (!JSVAL_IS_PRIMITIVE(*vp) || JSVAL_IS_NULL(*vp)) {
unsigned char *err = NULL; unsigned char *err = NULL;
int event_id; int event_id;
struct string_ event_name = NULL_STRING; struct string_ event_name = NULL_STRING;
JSObject *jsobj = JSVAL_TO_OBJECT(vp); JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
if (JS_FALSE == JS_ObjectIsFunction(ctx, jsobj)) if (JS_FALSE == JS_ObjectIsFunction(ctx, jsobj))
return JS_FALSE; return JS_FALSE;

View File

@ -80,7 +80,7 @@ smjs_location_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
(JSClass *) &location_array_class, NULL); (JSClass *) &location_array_class, NULL);
if (!ses) return JS_FALSE; if (!ses) return JS_FALSE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_FALSE; return JS_FALSE;
@ -97,7 +97,7 @@ smjs_location_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId
if (!index) { if (!index) {
JSObject *obj = smjs_get_view_state_object(&loc->vs); JSObject *obj = smjs_get_view_state_object(&loc->vs);
if (obj) object_to_jsval(ctx, &vp, obj); if (obj) object_to_jsval(ctx, vp, obj);
return JS_TRUE; return JS_TRUE;
} }
@ -227,17 +227,17 @@ session_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMuta
/* XXX: Lock session here if it is ever changed to have an OBJECT_HEAD. */ /* XXX: Lock session here if it is ever changed to have an OBJECT_HEAD. */
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case SESSION_VISITED: case SESSION_VISITED:
int_to_jsval(ctx, &vp, ses->status.visited); int_to_jsval(ctx, vp, ses->status.visited);
return JS_TRUE; return JS_TRUE;
case SESSION_HISTORY: { case SESSION_HISTORY: {
JSObject *obj = smjs_get_session_location_array_object(ses); JSObject *obj = smjs_get_session_location_array_object(ses);
if (obj) object_to_jsval(ctx, &vp, obj); if (obj) object_to_jsval(ctx, vp, obj);
return JS_TRUE; return JS_TRUE;
} }
@ -245,29 +245,29 @@ session_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMuta
struct uri *uri = have_location(ses) ? cur_loc(ses)->vs.uri struct uri *uri = have_location(ses) ? cur_loc(ses)->vs.uri
: ses->loading_uri; : ses->loading_uri;
if (uri) string_to_jsval(ctx, &vp, struri(uri)); if (uri) string_to_jsval(ctx, vp, struri(uri));
return JS_TRUE; return JS_TRUE;
} }
case SESSION_RELOADLEVEL: case SESSION_RELOADLEVEL:
int_to_jsval(ctx, &vp, ses->reloadlevel); int_to_jsval(ctx, vp, ses->reloadlevel);
return JS_TRUE; return JS_TRUE;
case SESSION_REDIRECT_CNT: case SESSION_REDIRECT_CNT:
int_to_jsval(ctx, &vp, ses->redirect_cnt); int_to_jsval(ctx, vp, ses->redirect_cnt);
return JS_TRUE; return JS_TRUE;
case SESSION_SEARCH_DIRECTION: case SESSION_SEARCH_DIRECTION:
string_to_jsval(ctx, &vp, ses->search_direction == 1 ? "down" string_to_jsval(ctx, vp, ses->search_direction == 1 ? "down"
: "up"); : "up");
return JS_TRUE; return JS_TRUE;
case SESSION_KBDPREFIX: case SESSION_KBDPREFIX:
int_to_jsval(ctx, &vp, ses->kbdprefix.repeat_count); int_to_jsval(ctx, vp, ses->kbdprefix.repeat_count);
return JS_TRUE; return JS_TRUE;
case SESSION_MARK_WAITING_FOR: case SESSION_MARK_WAITING_FOR:
string_to_jsval(ctx, &vp, ses->kbdprefix.mark == KP_MARK_NOTHING string_to_jsval(ctx, vp, ses->kbdprefix.mark == KP_MARK_NOTHING
? "nothing" ? "nothing"
: ses->kbdprefix.mark == KP_MARK_SET : ses->kbdprefix.mark == KP_MARK_SET
? "set" ? "set"
@ -275,11 +275,11 @@ session_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMuta
return JS_TRUE; return JS_TRUE;
case SESSION_EXIT_QUERY: case SESSION_EXIT_QUERY:
int_to_jsval(ctx, &vp, ses->exit_query); int_to_jsval(ctx, vp, ses->exit_query);
return JS_TRUE; return JS_TRUE;
case SESSION_INSERT_MODE: case SESSION_INSERT_MODE:
string_to_jsval(ctx, &vp, string_to_jsval(ctx, vp,
ses->insert_mode == INSERT_MODE_LESS ses->insert_mode == INSERT_MODE_LESS
? "disabled" ? "disabled"
: ses->insert_mode == INSERT_MODE_ON : ses->insert_mode == INSERT_MODE_ON
@ -288,18 +288,18 @@ session_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMuta
return JS_TRUE; return JS_TRUE;
case SESSION_NAVIGATE_MODE: case SESSION_NAVIGATE_MODE:
string_to_jsval(ctx, &vp, string_to_jsval(ctx, vp,
ses->navigate_mode == NAVIGATE_CURSOR_ROUTING ses->navigate_mode == NAVIGATE_CURSOR_ROUTING
? "cursor" ? "cursor"
: "linkwise"); : "linkwise");
return JS_TRUE; return JS_TRUE;
case SESSION_SEARCH_WORD: case SESSION_SEARCH_WORD:
string_to_jsval(ctx, &vp, ses->search_word); string_to_jsval(ctx, vp, ses->search_word);
return JS_TRUE; return JS_TRUE;
case SESSION_LAST_SEARCH_WORD: case SESSION_LAST_SEARCH_WORD:
string_to_jsval(ctx, &vp, ses->last_search_word); string_to_jsval(ctx, vp, ses->last_search_word);
return JS_TRUE; return JS_TRUE;
default: default:
@ -333,24 +333,24 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case SESSION_VISITED: case SESSION_VISITED:
ses->status.visited = atol(jsval_to_string(ctx, &vp)); ses->status.visited = atol(jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
/* SESSION_HISTORY is RO */ /* SESSION_HISTORY is RO */
/* SESSION_LOADING_URI is RO */ /* SESSION_LOADING_URI is RO */
case SESSION_RELOADLEVEL: case SESSION_RELOADLEVEL:
ses->reloadlevel = atol(jsval_to_string(ctx, &vp)); ses->reloadlevel = atol(jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
case SESSION_REDIRECT_CNT: case SESSION_REDIRECT_CNT:
ses->redirect_cnt = atol(jsval_to_string(ctx, &vp)); ses->redirect_cnt = atol(jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
case SESSION_SEARCH_DIRECTION: { case SESSION_SEARCH_DIRECTION: {
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -366,14 +366,14 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
return JS_TRUE; return JS_TRUE;
} }
case SESSION_KBDPREFIX: case SESSION_KBDPREFIX:
ses->kbdprefix.repeat_count = atol(jsval_to_string(ctx, &vp)); ses->kbdprefix.repeat_count = atol(jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
case SESSION_MARK_WAITING_FOR: { case SESSION_MARK_WAITING_FOR: {
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -395,7 +395,7 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -416,7 +416,7 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -435,7 +435,7 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -449,7 +449,7 @@ session_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSBool
unsigned char *str; unsigned char *str;
JSString *jsstr; JSString *jsstr;
jsstr = JS_ValueToString(ctx, vp); jsstr = JS_ValueToString(ctx, *vp);
if (!jsstr) return JS_TRUE; if (!jsstr) return JS_TRUE;
str = JS_EncodeString(ctx, jsstr); str = JS_EncodeString(ctx, jsstr);
@ -602,7 +602,7 @@ session_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
int index; int index;
struct window *tab; struct window *tab;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_FALSE; return JS_FALSE;
@ -618,7 +618,7 @@ session_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if ((void *) tab == (void *) &term->windows) return JS_FALSE; if ((void *) tab == (void *) &term->windows) return JS_FALSE;
tabobj = smjs_get_session_object(tab->data); tabobj = smjs_get_session_object(tab->data);
if (tabobj) object_to_jsval(ctx, &vp, tabobj); if (tabobj) object_to_jsval(ctx, vp, tabobj);
return JS_TRUE; return JS_TRUE;
} }

View File

@ -56,7 +56,7 @@ terminal_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMut
(JSClass *) &terminal_class, NULL); (JSClass *) &terminal_class, NULL);
if (!term) return JS_FALSE; /* already detached */ if (!term) return JS_FALSE; /* already detached */
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) return JS_FALSE; if (!JSID_IS_INT(id)) return JS_FALSE;
@ -64,7 +64,7 @@ terminal_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSMut
case TERMINAL_TAB: { case TERMINAL_TAB: {
JSObject *obj = smjs_get_session_array_object(term); JSObject *obj = smjs_get_session_array_object(term);
if (obj) object_to_jsval(ctx, &vp, obj); if (obj) object_to_jsval(ctx, vp, obj);
return JS_TRUE; return JS_TRUE;
} }
@ -163,7 +163,7 @@ terminal_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
int index; int index;
struct terminal *term; struct terminal *term;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_FALSE; return JS_FALSE;
@ -176,7 +176,7 @@ terminal_array_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
if ((void *) term == (void *) &terminals) return JS_FALSE; if ((void *) term == (void *) &terminals) return JS_FALSE;
obj = smjs_get_terminal_object(term); obj = smjs_get_terminal_object(term);
if (obj) object_to_jsval(ctx, &vp, obj); if (obj) object_to_jsval(ctx, vp, obj);
return JS_TRUE; return JS_TRUE;
; ;

View File

@ -67,18 +67,18 @@ view_state_get_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSM
(JSClass *) &view_state_class, NULL); (JSClass *) &view_state_class, NULL);
if (!vs) return JS_FALSE; if (!vs) return JS_FALSE;
undef_to_jsval(ctx, &vp); undef_to_jsval(ctx, vp);
if (!JSID_IS_INT(id)) if (!JSID_IS_INT(id))
return JS_FALSE; return JS_FALSE;
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case VIEW_STATE_PLAIN: case VIEW_STATE_PLAIN:
vp = INT_TO_JSVAL(vs->plain); *vp = INT_TO_JSVAL(vs->plain);
return JS_TRUE; return JS_TRUE;
case VIEW_STATE_URI: case VIEW_STATE_URI:
vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx, *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(smjs_ctx,
struri(vs->uri))); struri(vs->uri)));
return JS_TRUE; return JS_TRUE;
@ -117,7 +117,7 @@ view_state_set_property(JSContext *ctx, JSHandleObject hobj, JSHandleId hid, JSB
switch (JSID_TO_INT(id)) { switch (JSID_TO_INT(id)) {
case VIEW_STATE_PLAIN: { case VIEW_STATE_PLAIN: {
vs->plain = atol(jsval_to_string(ctx, &vp)); vs->plain = atol(jsval_to_string(ctx, vp));
return JS_TRUE; return JS_TRUE;
} }
@ -196,7 +196,7 @@ smjs_elinks_get_view_state(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
JSObject *vs_obj; JSObject *vs_obj;
struct view_state *vs; struct view_state *vs;
vp = JSVAL_NULL; *vp = JSVAL_NULL;
if (!smjs_ses || !have_location(smjs_ses)) return JS_TRUE; if (!smjs_ses || !have_location(smjs_ses)) return JS_TRUE;
@ -206,7 +206,7 @@ smjs_elinks_get_view_state(JSContext *ctx, JSHandleObject hobj, JSHandleId hid,
vs_obj = smjs_get_view_state_object(vs); vs_obj = smjs_get_view_state_object(vs);
if (!vs_obj) return JS_TRUE; if (!vs_obj) return JS_TRUE;
vp = OBJECT_TO_JSVAL(vs_obj); *vp = OBJECT_TO_JSVAL(vs_obj);
return JS_TRUE; return JS_TRUE;
} }